]> source.dussan.org Git - jquery.git/commitdiff
Fix #14074: element id="nodeName". Close gh-1389.
authorRichard Gibson <richard.gibson@gmail.com>
Wed, 18 Sep 2013 13:41:07 +0000 (09:41 -0400)
committerRichard Gibson <richard.gibson@gmail.com>
Thu, 7 Nov 2013 16:57:41 +0000 (11:57 -0500)
(cherry picked from commit 126d596b56924613687329b7aab4f0cdf4b593b3)

Conflicts:

src/data.js
src/data/accepts.js
test/unit/core.js
test/unit/data.js

src/data/accepts.js
test/data/core/aliased.html [new file with mode: 0644]
test/unit/core.js
test/unit/data.js

index f3abe06afe005c2325478c2d063be24ff01808b4..291c7b47517a97629bcc4b3dc1d148d8c1eeed3d 100644 (file)
@@ -12,8 +12,8 @@ jQuery.acceptData = function( owner ) {
        //    - Node.DOCUMENT_NODE
        //  - Object
        //    - Any
-       return owner.nodeType ?
-               owner.nodeType === 1 || owner.nodeType === 9 : true;
+       /* jshint -W018 */
+       return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
 };
 
 return jQuery.acceptData;
diff --git a/test/data/core/aliased.html b/test/data/core/aliased.html
new file mode 100644 (file)
index 0000000..ed06606
--- /dev/null
@@ -0,0 +1,24 @@
+<!doctype html>
+<html>
+<head>
+       <meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
+       <title>alias-masked DOM properties (#14074)</title>
+       <script>
+               var errors = [];
+               window.onerror = function( errorMessage, filePath, lineNumber ) {
+                       errors.push( errorMessage );
+               };
+       </script>
+       <script src="../../jquery.js"></script>
+</head>
+<body>
+       <form>
+               <input type="text" id="nodeName"/>
+       </form>
+       <script>
+               jQuery(function() {
+                       window.parent.iframeCallback( errors );
+               });
+       </script>
+</body>
+</html>
index 5677ddc3d3b5d54794c0a38d141422cc18bbc73b..d00f0fd763ab7e9187763881b7445e374fbea8c1 100644 (file)
@@ -1445,3 +1445,10 @@ testIframeWithCallback( "document ready when jQuery loaded asynchronously (#1365
        expect( 1 );
        equal( true, ready, "document ready correctly fired when jQuery is loaded after DOMContentLoaded" );
 });
+
+testIframeWithCallback( "Tolerating alias-masked DOM properties (#14074)", "core/aliased.html",
+       function( errors ) {
+                       expect( 1 );
+                       deepEqual( errors, [], "jQuery loaded" );
+       }
+);
index 086067cdcbceaf0a8fd176c48f1a4d241f9a05e1..b63c79b92257543c508fac70de9a0a299a0d0bfe 100644 (file)
@@ -766,14 +766,30 @@ test(".data doesn't throw when calling selection is empty. #13551", function() {
        }
 });
 
-test("jQuery.acceptData", 6, function() {
+test("jQuery.acceptData", 11, function() {
+       var flash, applet;
+
        ok( jQuery.acceptData( document ), "document" );
        ok( jQuery.acceptData( document.documentElement ), "documentElement" );
        ok( jQuery.acceptData( {} ), "object" );
+       ok( jQuery.acceptData( document.createElement( "embed" ) ), "embed" );
+       ok( jQuery.acceptData( document.createElement( "applet" ) ), "applet" );
+
+       flash = document.createElement( "object" );
+       flash.setAttribute( "classid", "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" );
+       ok( jQuery.acceptData( flash ), "flash" );
 
-       ok( !jQuery.acceptData( document.createComment("") ), "comment" );
-       ok( !jQuery.acceptData( document.createTextNode("") ), "text" );
+       applet = document.createElement( "object" );
+       applet.setAttribute( "classid", "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" );
+       ok( jQuery.acceptData( applet ), "applet" );
+
+       ok( !jQuery.acceptData( document.createComment( "" ) ), "comment" );
+       ok( !jQuery.acceptData( document.createTextNode( "" ) ), "text" );
        ok( !jQuery.acceptData( document.createDocumentFragment() ), "documentFragment" );
+
+       ok( jQuery.acceptData(
+               jQuery( "#form" ).append( "<input id='nodeType'/><input id='nodeName'/>" )[ 0 ] ),
+               "form with aliased DOM properties" );
 });
 
 test("Check proper data removal of non-element descendants nodes (#8335)", 1, function() {