Permalink
Browse files

do not cache html5 elements fixes issue #54 (thx to @jamesreggio)

  • Loading branch information...
1 parent bd0fefe commit 9aa5bcdca367fd86ec5d5b73ca4d95e032a0f502 @aFarkas committed Mar 25, 2012
Showing with 10 additions and 10 deletions.
  1. +5 −5 src/html5shiv-printshiv.js
  2. +5 −5 src/html5shiv.js
@@ -6,7 +6,7 @@
/** Used to skip problem elements */
var reSkip = /^<|^(?:button|form|map|select|textarea|object|iframe)$/i;
-
+
/** Not all elements can be cloned in IE (this list can be shortend) **/
var saveClones = /^<|^(?:a|b|button|code|div|fieldset|form|h1|h2|h3|h4|h5|h6|i|iframe|img|input|label|li|link|ol|option|p|param|q|script|select|span|strong|style|table|tbody|td|textarea|tfoot|th|thead|tr|ul)$/i;
@@ -93,7 +93,7 @@
if(!html5.shivMethods){
docCreateElement(nodeName);
}
-
+
var node;
if(cache[nodeName]){
@@ -103,15 +103,15 @@
} else {
node = docCreateElement(nodeName);
}
-
+
// Avoid adding some elements to fragments in IE < 9 because
// * Attributes like `name` or `type` cannot be set/changed once an element
// is inserted into a document/fragment
// * Link elements with `src` attributes that are inaccessible, as with
// a 403 response, will cause the tab/window to crash
// * Script elements appended to fragments will execute when their `src`
// or `text` property is set
-
+
return node.canHaveChildren && !reSkip.test(nodeName) ? frag.appendChild(node) : node;
};
@@ -120,7 +120,7 @@
'h.shivMethods&&(' +
// unroll the `createElement` calls
getElements().join().replace(/\w+/g, function(nodeName) {
- cache[nodeName] = docCreateElement(nodeName);
+ docCreateElement(nodeName);
frag.createElement(nodeName);
return 'c("' + nodeName + '")';
}) +
View
@@ -6,7 +6,7 @@
/** Used to skip problem elements */
var reSkip = /^<|^(?:button|form|map|select|textarea|object|iframe)$/i;
-
+
/** Not all elements can be cloned in IE (this list can be shortend) **/
var saveClones = /^<|^(?:a|b|button|code|div|fieldset|form|h1|h2|h3|h4|h5|h6|i|iframe|img|input|label|li|link|ol|option|p|param|q|script|select|span|strong|style|table|tbody|td|textarea|tfoot|th|thead|tr|ul)$/i;
@@ -93,17 +93,17 @@
if(!html5.shivMethods){
docCreateElement(nodeName);
}
-
+
var node;
-
+
if(cache[nodeName]){
node = cache[nodeName].cloneNode();
} else if(saveClones.test(nodeName)){
node = (cache[nodeName] = docCreateElement(nodeName)).cloneNode();
} else {
node = docCreateElement(nodeName);
}
-
+
// Avoid adding some elements to fragments in IE < 9 because
// * Attributes like `name` or `type` cannot be set/changed once an element
// is inserted into a document/fragment
@@ -119,7 +119,7 @@
'h.shivMethods&&(' +
// unroll the `createElement` calls
getElements().join().replace(/\w+/g, function(nodeName) {
- cache[nodeName] = docCreateElement(nodeName);
+ docCreateElement(nodeName);
frag.createElement(nodeName);
return 'c("' + nodeName + '")';
}) +

0 comments on commit 9aa5bcd

Please sign in to comment.