@@ -56,6 +56,19 @@ map.rect = [
5656 '</svg>'
5757]
5858
59+ /**
60+ * Check if a node is a supported template node with a
61+ * DocumentFragment content.
62+ *
63+ * @param {Node } node
64+ * @return {Boolean }
65+ */
66+
67+ function isRealTemplate ( node ) {
68+ return _ . isTemplate ( node ) &&
69+ node . content instanceof DocumentFragment
70+ }
71+
5972var tagRE = / < ( [ \w : ] + ) /
6073var entityRE = / & \w + ; /
6174
@@ -120,10 +133,7 @@ function stringToFragment (templateString) {
120133function nodeToFragment ( node ) {
121134 // if its a template tag and the browser supports it,
122135 // its content is already a document fragment.
123- if (
124- _ . isTemplate ( node ) &&
125- node . content instanceof DocumentFragment
126- ) {
136+ if ( isRealTemplate ( node ) ) {
127137 _ . trimNode ( node . content )
128138 return node . content
129139 }
@@ -174,16 +184,21 @@ var hasTextareaCloneBug = _.inBrowser
174184 */
175185
176186exports . clone = function ( node ) {
177- var res = node . cloneNode ( true )
178187 if ( ! node . querySelectorAll ) {
179- return res
188+ return node . cloneNode ( )
180189 }
190+ var res = node . cloneNode ( true )
181191 var i , original , cloned
182192 /* istanbul ignore if */
183193 if ( hasBrokenTemplate ) {
194+ var clone = res
195+ if ( isRealTemplate ( node ) ) {
196+ node = node . content
197+ clone = res . content
198+ }
184199 original = node . querySelectorAll ( 'template' )
185200 if ( original . length ) {
186- cloned = res . querySelectorAll ( 'template' )
201+ cloned = clone . querySelectorAll ( 'template' )
187202 i = cloned . length
188203 while ( i -- ) {
189204 cloned [ i ] . parentNode . replaceChild (
0 commit comments