Skip to content

Commit 9aa5bcd

Browse files
author
aFarkas
committed
do not cache html5 elements fixes issue #54 (thx to @jamesreggio)
1 parent bd0fefe commit 9aa5bcd

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/html5shiv-printshiv.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
/** Used to skip problem elements */
88
var reSkip = /^<|^(?:button|form|map|select|textarea|object|iframe)$/i;
9-
9+
1010
/** Not all elements can be cloned in IE (this list can be shortend) **/
1111
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;
1212

@@ -93,7 +93,7 @@
9393
if(!html5.shivMethods){
9494
docCreateElement(nodeName);
9595
}
96-
96+
9797
var node;
9898

9999
if(cache[nodeName]){
@@ -103,15 +103,15 @@
103103
} else {
104104
node = docCreateElement(nodeName);
105105
}
106-
106+
107107
// Avoid adding some elements to fragments in IE < 9 because
108108
// * Attributes like `name` or `type` cannot be set/changed once an element
109109
// is inserted into a document/fragment
110110
// * Link elements with `src` attributes that are inaccessible, as with
111111
// a 403 response, will cause the tab/window to crash
112112
// * Script elements appended to fragments will execute when their `src`
113113
// or `text` property is set
114-
114+
115115
return node.canHaveChildren && !reSkip.test(nodeName) ? frag.appendChild(node) : node;
116116
};
117117

@@ -120,7 +120,7 @@
120120
'h.shivMethods&&(' +
121121
// unroll the `createElement` calls
122122
getElements().join().replace(/\w+/g, function(nodeName) {
123-
cache[nodeName] = docCreateElement(nodeName);
123+
docCreateElement(nodeName);
124124
frag.createElement(nodeName);
125125
return 'c("' + nodeName + '")';
126126
}) +

src/html5shiv.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
/** Used to skip problem elements */
88
var reSkip = /^<|^(?:button|form|map|select|textarea|object|iframe)$/i;
9-
9+
1010
/** Not all elements can be cloned in IE (this list can be shortend) **/
1111
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;
1212

@@ -93,17 +93,17 @@
9393
if(!html5.shivMethods){
9494
docCreateElement(nodeName);
9595
}
96-
96+
9797
var node;
98-
98+
9999
if(cache[nodeName]){
100100
node = cache[nodeName].cloneNode();
101101
} else if(saveClones.test(nodeName)){
102102
node = (cache[nodeName] = docCreateElement(nodeName)).cloneNode();
103103
} else {
104104
node = docCreateElement(nodeName);
105105
}
106-
106+
107107
// Avoid adding some elements to fragments in IE < 9 because
108108
// * Attributes like `name` or `type` cannot be set/changed once an element
109109
// is inserted into a document/fragment
@@ -119,7 +119,7 @@
119119
'h.shivMethods&&(' +
120120
// unroll the `createElement` calls
121121
getElements().join().replace(/\w+/g, function(nodeName) {
122-
cache[nodeName] = docCreateElement(nodeName);
122+
docCreateElement(nodeName);
123123
frag.createElement(nodeName);
124124
return 'c("' + nodeName + '")';
125125
}) +

0 commit comments

Comments
 (0)