Skip to content

Commit de3b59f

Browse files
committed
use clone instead of stringToFrag for normal node in template parser (fix #760)
1 parent 3a9bfff commit de3b59f

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/parsers/template.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,19 @@ function nodeToFragment (node) {
126126
) {
127127
return node.content
128128
}
129-
return tag === 'SCRIPT'
130-
? stringToFragment(node.textContent)
131-
: stringToFragment(node.innerHTML)
129+
// script template
130+
if (tag === 'SCRIPT') {
131+
return stringToFragment(node.textContent)
132+
}
133+
// normal node, clone it to avoid mutating the original
134+
var clone = exports.clone(node)
135+
var frag = document.createDocumentFragment()
136+
var child
137+
/* jshint boss:true */
138+
while (child = clone.firstChild) {
139+
frag.appendChild(child)
140+
}
141+
return frag
132142
}
133143

134144
// Test for the presence of the Safari template cloning bug

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy