Skip to content

Commit

Permalink
Make sure that expando properties aren't set on embed, applet, or obj…
Browse files Browse the repository at this point in the history
…ect elements. An uncatchable exception is thrown and we must avoid it. Fixes #1675 and #2349.
  • Loading branch information
jeresig committed Dec 7, 2009
1 parent 7d36ccf commit 5980292
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,19 @@ jQuery.extend({

expando:expando,

// The following elements throw uncatchable exceptions if you
// attempt to add expando properties to them.
noData: {
"embed": true,
"object": true,
"applet": true
},

data: function( elem, name, data ) {
if ( jQuery.noData[elem.nodeNode.toLowerCase()] ) {
return;
}

elem = elem == window ?
windowData :
elem;
Expand Down Expand Up @@ -43,6 +55,10 @@ jQuery.extend({
},

removeData: function( elem, name ) {
if ( jQuery.noData[elem.nodeNode.toLowerCase()] ) {
return;
}

elem = elem == window ?
windowData :
elem;
Expand Down
2 changes: 1 addition & 1 deletion src/manipulation.js
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ jQuery.extend({

function cleanData( elems ) {
for ( var i = 0, elem, id; (elem = elems[i]) != null; i++ ) {
if ( (id = elem[expando]) ) {
if ( !jQuery.noData[elem.nodeNode.toLowerCase()] && (id = elem[expando]) ) {
delete jQuery.cache[ id ];
}
}
Expand Down

1 comment on commit 5980292

@jeresig
Copy link
Member Author

@jeresig jeresig commented on 5980292 Dec 7, 2009

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed obvious dumb-ness in ed93204.

Please sign in to comment.