Permalink
Browse files

document.register only triggers document-wide upgrade when called aft…

…er initial load is complete, pre-load-complete registrations are processed in one step on load-complete
  • Loading branch information...
sjmiles committed Apr 23, 2013
1 parent b3f842a commit 2c80460cba9f742e4f3fef434b225ef1829de39b
Showing with 8 additions and 5 deletions.
  1. +6 −5 src/CustomElements.js
  2. +2 −0 src/boot.js
View
@@ -113,10 +113,11 @@ function register(inName, inOptions) {
// 7.1.8. Return the output of the previous step.
definition.ctor = generateConstructor(definition);
definition.ctor.prototype = definition.prototype;
- // blanket upgrade (?)
- // TODO(sjmiles): add flag to enable this after the initial sweep
- // of static content
- //scope.addedNode(document);
+ // if initial parsing is complete
+ if (scope.ready) {
+ // upgrade any pre-existing nodes of this type
+ scope.upgradeAll(document);
+ }
return definition.ctor;
}
@@ -185,7 +186,7 @@ function upgrade(inElement, inDefinition) {
inElement.__upgraded__ = true;
// there should never be a shadow root on inElement at this point
// we require child nodes be upgraded before ready
- scope.addedSubtree(inElement);
+ scope.upgradeSubtree(inElement);
// lifecycle management
ready(inElement);
// OUTPUT
View
@@ -21,6 +21,8 @@ function bootstrap() {
setTimeout(function() {
// parse document
CustomElements.parser.parse(document);
+ // set internal flag
+ CustomElements.ready = true;
// notify system
document.body.dispatchEvent(
new CustomEvent('WebComponentsReady', {bubbles: true})

0 comments on commit 2c80460

Please sign in to comment.