From 59802928566b6be3a66d65e77c2418fff37e6f5f Mon Sep 17 00:00:00 2001 From: John Resig Date: Sun, 6 Dec 2009 20:00:31 -0800 Subject: [PATCH] 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. --- src/data.js | 16 ++++++++++++++++ src/manipulation.js | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/data.js b/src/data.js index 1d993fe58..44d77a902 100644 --- a/src/data.js +++ b/src/data.js @@ -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; @@ -43,6 +55,10 @@ jQuery.extend({ }, removeData: function( elem, name ) { + if ( jQuery.noData[elem.nodeNode.toLowerCase()] ) { + return; + } + elem = elem == window ? windowData : elem; diff --git a/src/manipulation.js b/src/manipulation.js index a8cb484bb..e1657a8cf 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -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 ]; } } -- 2.39.5