mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Fix #14074: element id="nodeName". Close gh-1389.
This commit is contained in:
parent
d0b8f9fa93
commit
126d596b56
@ -238,12 +238,12 @@ function internalRemoveData( elem, name, pvt ) {
|
||||
jQuery.extend({
|
||||
cache: {},
|
||||
|
||||
// The following elements throw uncatchable exceptions if you
|
||||
// attempt to add expando properties to them.
|
||||
// The following elements (space-suffixed to avoid Object.prototype collisions)
|
||||
// throw uncatchable exceptions if you attempt to set expando properties
|
||||
noData: {
|
||||
"applet ": true,
|
||||
"embed ": true,
|
||||
// Ban all objects except for Flash (which handle expandos)
|
||||
// ...but Flash objects (which have this classid) *can* handle expandos
|
||||
"object ": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
|
||||
},
|
||||
|
||||
|
@ -6,15 +6,15 @@ define([
|
||||
* Determines whether an object can have data
|
||||
*/
|
||||
jQuery.acceptData = function( elem ) {
|
||||
// Do not set data on non-element because it will not be cleared (#8335).
|
||||
if ( elem.nodeType && elem.nodeType !== 1 && elem.nodeType !== 9 ) {
|
||||
return false;
|
||||
}
|
||||
var noData = jQuery.noData[ (elem.nodeName + " ").toLowerCase() ],
|
||||
nodeType = +elem.nodeType || 1;
|
||||
|
||||
var noData = elem.nodeName && jQuery.noData[ elem.nodeName.toLowerCase() ];
|
||||
// Do not set data on non-element DOM nodes because it will not be cleared (#8335).
|
||||
return nodeType !== 1 && nodeType !== 9 ?
|
||||
false :
|
||||
|
||||
// nodes accept data unless otherwise specified; rejection can be conditional
|
||||
return !noData || noData !== true && elem.getAttribute("classid") === noData;
|
||||
// Nodes accept data unless otherwise specified; rejection can be conditional
|
||||
!noData || noData !== true && elem.getAttribute("classid") === noData;
|
||||
};
|
||||
|
||||
return jQuery.acceptData;
|
||||
|
24
test/data/core/aliased.html
Normal file
24
test/data/core/aliased.html
Normal file
@ -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>
|
@ -1419,3 +1419,10 @@ testIframeWithCallback( "Conditional compilation compatibility (#13274)", "core/
|
||||
deepEqual( errors, [], "No errors" );
|
||||
ok( $(), "jQuery executes" );
|
||||
});
|
||||
|
||||
testIframeWithCallback( "Tolerating alias-masked DOM properties (#14074)", "core/aliased.html",
|
||||
function( errors ) {
|
||||
expect( 1 );
|
||||
deepEqual( errors, [], "jQuery loaded" );
|
||||
}
|
||||
);
|
||||
|
@ -142,7 +142,7 @@ test("Data is not being set on comment and text nodes", function() {
|
||||
});
|
||||
|
||||
test("jQuery.acceptData", function() {
|
||||
expect(9);
|
||||
expect( 10 );
|
||||
|
||||
var flash, applet;
|
||||
|
||||
@ -162,6 +162,10 @@ test("jQuery.acceptData", function() {
|
||||
|
||||
ok( !jQuery.acceptData( document.createComment( "" ) ), "comment" );
|
||||
ok( !jQuery.acceptData( document.createTextNode( "" ) ), "text" );
|
||||
|
||||
ok( jQuery.acceptData(
|
||||
jQuery( "#form" ).append( "<input id='nodeType'/><input id='nodeName'/>" )[ 0 ] ),
|
||||
"form with aliased DOM properties" );
|
||||
});
|
||||
|
||||
// attempting to access the data of an undefined jQuery element should be undefined
|
||||
|
Loading…
Reference in New Issue
Block a user