Skip to content

Commit 6f58626

Browse files
committed
move content resolution to after created hook
1 parent c67685b commit 6f58626

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/compiler.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,11 @@ function Compiler (vm, options) {
163163

164164
// COMPILE ----------------------------------------------------------------
165165

166+
// before compiling, resolve content insertion points
167+
if (options.template) {
168+
this.resolveContent()
169+
}
170+
166171
// now parse the DOM and bind directives.
167172
// During this stage, we will also create bindings for
168173
// encountered keypaths that don't have a binding yet.
@@ -237,7 +242,6 @@ CompilerProto.setupElement = function (options) {
237242
el.appendChild(template.cloneNode(true))
238243
}
239244

240-
this.setupContent(el)
241245
}
242246

243247
// apply element options
@@ -257,9 +261,9 @@ CompilerProto.setupElement = function (options) {
257261
* Deal with <content> insertion points
258262
* per the Web Components spec
259263
*/
260-
CompilerProto.setupContent = function (el) {
264+
CompilerProto.resolveContent = function () {
261265

262-
var outlets = slice.call(el.getElementsByTagName('content')),
266+
var outlets = slice.call(this.el.getElementsByTagName('content')),
263267
raw = this.rawContent,
264268
outlet, select, i, j, main
265269

@@ -289,7 +293,7 @@ CompilerProto.setupContent = function (el) {
289293
insert(outlet, outlet.content)
290294
}
291295
// finally insert the main content
292-
if (raw) {
296+
if (raw && main) {
293297
insert(main, slice.call(raw.childNodes))
294298
}
295299
}

0 commit comments

Comments
 (0)