Skip to content

Commit 5980292

Browse files
committed
Make sure that expando properties aren't set on embed, applet, or object elements. An uncatchable exception is thrown and we must avoid it. Fixes #1675 and #2349.
1 parent 7d36ccf commit 5980292

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/data.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,19 @@ jQuery.extend({
66

77
expando:expando,
88

9+
// The following elements throw uncatchable exceptions if you
10+
// attempt to add expando properties to them.
11+
noData: {
12+
"embed": true,
13+
"object": true,
14+
"applet": true
15+
},
16+
917
data: function( elem, name, data ) {
18+
if ( jQuery.noData[elem.nodeNode.toLowerCase()] ) {
19+
return;
20+
}
21+
1022
elem = elem == window ?
1123
windowData :
1224
elem;
@@ -43,6 +55,10 @@ jQuery.extend({
4355
},
4456

4557
removeData: function( elem, name ) {
58+
if ( jQuery.noData[elem.nodeNode.toLowerCase()] ) {
59+
return;
60+
}
61+
4662
elem = elem == window ?
4763
windowData :
4864
elem;

src/manipulation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ jQuery.extend({
463463

464464
function cleanData( elems ) {
465465
for ( var i = 0, elem, id; (elem = elems[i]) != null; i++ ) {
466-
if ( (id = elem[expando]) ) {
466+
if ( !jQuery.noData[elem.nodeNode.toLowerCase()] && (id = elem[expando]) ) {
467467
delete jQuery.cache[ id ];
468468
}
469469
}

0 commit comments

Comments
 (0)