From 100733ca1024be01e05d081ec9476d114e0cc5ff Mon Sep 17 00:00:00 2001 From: Steve Orvell Date: Thu, 1 Aug 2013 19:02:44 -0700 Subject: [PATCH 01/19] adapt to mdv's removal of createBinding; override bind instead. --- src/instance/mdv.js | 6 +++--- test/html/attr-mustache.html | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/instance/mdv.js b/src/instance/mdv.js index f206e32f46..59f42e0d58 100644 --- a/src/instance/mdv.js +++ b/src/instance/mdv.js @@ -19,15 +19,15 @@ instanceTemplate: function(template) { return template.createInstance(this, mdv_syntax); }, - createBinding: function(name, model, path) { - //console.log(arguments); + bind: function(name, model, path) { var property = this.propertyForAttribute(name); if (property) { + this.unbind(name); // use n-way Polymer binding var observer = this.bindProperty(property, model, path); // stick path on observer so it's available via this.bindings observer.path = path; - return observer; + return this.bindings[name] = observer; } else { return this.super(arguments); } diff --git a/test/html/attr-mustache.html b/test/html/attr-mustache.html index 7b7b431be0..fd3aa8ad86 100644 --- a/test/html/attr-mustache.html +++ b/test/html/attr-mustache.html @@ -13,8 +13,8 @@ + + + + + +
+ + +
+ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/js/register.js b/test/js/register.js index 4ff02de121..274e04dfed 100644 --- a/test/js/register.js +++ b/test/js/register.js @@ -49,3 +49,7 @@ htmlSuite('element callbacks', function() { htmlSuite('element script', function() { htmlTest('html/element-script.html'); }); + +htmlSuite('element registration', function() { + htmlTest('html/element-registration.html'); +}); From 244a0040b0b0d0e170d37043ea23f9ab10c35e71 Mon Sep 17 00:00:00 2001 From: "Scott J. Miles" Date: Fri, 2 Aug 2013 00:47:05 -0700 Subject: [PATCH 04/19] towards using mocha/chai from tools --- test/html/callbacks.html | 2 +- tools | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/html/callbacks.html b/test/html/callbacks.html index e4bcba05be..ed6e0ad07a 100644 --- a/test/html/callbacks.html +++ b/test/html/callbacks.html @@ -4,7 +4,7 @@ event path - + diff --git a/tools b/tools index 5d50474984..313f7524ce 160000 --- a/tools +++ b/tools @@ -1 +1 @@ -Subproject commit 5d504749846cc8df777ab6c493d7169ddfc8d638 +Subproject commit 313f7524ce37689ebfb60c81f7bda721535467cf From f72698d3fdfbc6d17845f7dba17fab1aa3e9e634 Mon Sep 17 00:00:00 2001 From: "Scott J. Miles" Date: Fri, 2 Aug 2013 01:44:03 -0700 Subject: [PATCH 05/19] inoculate element registration to the effects of load order --- src/declaration/polymer-element.js | 40 ++++++---- test/html/element-registration.html | 116 ++++++++++++++++++++++++++-- test/js/register.js | 4 +- 3 files changed, 138 insertions(+), 22 deletions(-) diff --git a/src/declaration/polymer-element.js b/src/declaration/polymer-element.js index 74260fe053..40dd8e75e6 100644 --- a/src/declaration/polymer-element.js +++ b/src/declaration/polymer-element.js @@ -32,7 +32,7 @@ function notifyPrototype(name) { if (waitPrototype[name]) { - waitPrototype[name].define(); + waitPrototype[name].registerWhenReady(); } } @@ -43,7 +43,7 @@ var waiting = waitSuper[name]; if (waiting) { waiting.forEach(function(w) { - w.define(); + w.registerWhenReady(); }); } } @@ -74,22 +74,32 @@ extend(prototype, { // TODO(sjmiles): temporary BC readyCallback: function() { - this._createdCallback(); + this.createdCallback(); }, createdCallback: function() { - this._createdCallback(); - }, - // custom element processing - _createdCallback: function() { - // fetch our element name + // fetch the element name this.name = this.getAttribute('name'); - if (getRegisteredPrototype(this.name)) { - this.define(); - } else { - waitPrototype[this.name] = this; - } + // install element definition, if ready + this.registerWhenReady(); }, - define: function() { + registerWhenReady: function() { + var name = this.name; + // if we have no prototype + if (!getRegisteredPrototype(name)) { + // then wait for a prototype + waitPrototype[name] = this; + // if we are not explicitly async, + // then wait for end of microtask(-ish) + // and use whatever prototype is available + if (!this.hasAttribute('async')) { + setTimeout(function() { + if (!getRegisteredPrototype(name)) { + element(name, null); + } + }, 0); + } + return; + } // fetch our extendee name var extnds = this.getAttribute('extends'); // if extending a custom element... @@ -100,7 +110,7 @@ return; } } - this.register(this.name, extnds); + this.register(name, extnds); }, register: function(name, extnds) { // build prototype combining extendee, Polymer base, and named api diff --git a/test/html/element-registration.html b/test/html/element-registration.html index c17d0c68f8..bbf415b9f2 100644 --- a/test/html/element-registration.html +++ b/test/html/element-registration.html @@ -9,16 +9,37 @@
- +
- + + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + - + + +