Permalink
Browse files

updated to noConflict srcDoc instead of _srcDoc

  • Loading branch information...
1 parent f12c598 commit da3d4ef4957a5fab3efa3943bea27a8cde5ecb43 @tbranyen tbranyen committed Jun 13, 2012
Showing with 25 additions and 2 deletions.
  1. +1 −1 srcdoc-polyfill-0.1.0.min.js
  2. +1 −1 srcdoc-polyfill.js
  3. +3 −0 test/index.html
  4. +20 −0 test/tests.js
Oops, something went wrong.
View
@@ -1,7 +1,7 @@
(function( window, document, undefined ) {
var idx, iframes;
- var _srcDoc = window._srcDoc;
+ var _srcDoc = window.srcDoc;
var isCompliant = !!("srcdoc" in document.createElement("iframe"));
var implementations = {
compliant: function( iframe, content ) {
View
@@ -9,6 +9,9 @@
<script src="lib/qunit-1.5.0.js"></script>
<script src="lib/jquery-1.7.2.js"></script>
+ <!-- Used for noConflict testing -->
+ <script>window.srcDoc = "old";</script>
+
<!-- Source files -->
<script src="../srcdoc-polyfill.js"></script>
</head>
View
@@ -23,6 +23,26 @@ function createDocument( iframe, insertions ) {
doc.close();
}
+module("noConflict", {
+ teardown: function() {
+ // Restore srcDoc to the global
+ window.srcDoc = window._srcDoc;
+
+ // Remove the global reference
+ delete window._srcDoc;
+ }
+});
+
+test("will restore original value", 2, function() {
+ equal(typeof window.srcDoc, "object",
+ "srcDoc has been overwritten to an object");
+
+ // Restore to old srcDoc, and keep a copy of srcDoc in window._srcDoc
+ window._srcDoc = window.srcDoc.noConflict();
+
+ equal(window.srcDoc, "old", "srcDoc has been restored to the old value");
+});
+
module("Explicit shimming", {
setup: function() {
this.$harness = $("<iframe>").appendTo("#qunit-fixture");

0 comments on commit da3d4ef

Please sign in to comment.