Skip to content

Commit eb5c80a

Browse files
committed
use more thorough cloning to deal with Safari template clone bug (fix #1095)
1 parent 563b063 commit eb5c80a

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/element-directives/content.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var _ = require('../util')
2+
var clone = require('../parsers/template').clone
23

34
// This is the elementDirective that handles <content>
45
// transclusions. It relies on the raw content of an
@@ -100,10 +101,10 @@ function extractFragment (nodes, parent, main) {
100101
// intact. this ensures proper re-compilation in cases
101102
// where the outlet is inside a conditional block
102103
if (main && !node.__v_selected) {
103-
frag.appendChild(node.cloneNode(true))
104+
frag.appendChild(clone(node))
104105
} else if (!main && node.parentNode === parent) {
105106
node.__v_selected = true
106-
frag.appendChild(node.cloneNode(true))
107+
frag.appendChild(clone(node))
107108
}
108109
}
109110
return frag

src/parsers/template.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ var hasTextareaCloneBug = _.inBrowser
173173

174174
exports.clone = function (node) {
175175
var res = node.cloneNode(true)
176+
if (!node.querySelectorAll) {
177+
return res
178+
}
176179
var i, original, cloned
177180
/* istanbul ignore if */
178181
if (hasBrokenTemplate) {
@@ -182,7 +185,7 @@ exports.clone = function (node) {
182185
i = cloned.length
183186
while (i--) {
184187
cloned[i].parentNode.replaceChild(
185-
original[i].cloneNode(true),
188+
exports.clone(original[i]),
186189
cloned[i]
187190
)
188191
}
@@ -229,7 +232,7 @@ exports.parse = function (template, clone, noSelector) {
229232
// do nothing
230233
if (template instanceof DocumentFragment) {
231234
return clone
232-
? template.cloneNode(true)
235+
? exports.clone(template)
233236
: template
234237
}
235238

0 commit comments

Comments
 (0)