From 2d97cd7b50d21daa2b52d243ca29827b2b4f6d78 Mon Sep 17 00:00:00 2001 From: Kevin Schaaf Date: Wed, 7 Oct 2015 17:34:56 -0700 Subject: [PATCH] Add templatizer tests. Fix issues from tests. --- src/lib/template/templatizer.html | 14 +- src/standard/notify-path.html | 2 + test/runner.html | 1 + test/unit/templatizer-elements.html | 221 +++++++++++++++++++++++++ test/unit/templatizer.html | 241 ++++++++++++++++++++++++++++ 5 files changed, 473 insertions(+), 6 deletions(-) create mode 100644 test/unit/templatizer-elements.html create mode 100644 test/unit/templatizer.html diff --git a/src/lib/template/templatizer.html b/src/lib/template/templatizer.html index 6d209c60de..edc12c1a31 100644 --- a/src/lib/template/templatizer.html +++ b/src/lib/template/templatizer.html @@ -109,15 +109,15 @@ // archetypes do special caching this._customPrepAnnotations(archetype, template); + // forward parent properties to archetype + this._prepParentProperties(archetype, template); + // setup accessors archetype._prepEffects(); this._customPrepEffects(archetype); archetype._prepBehaviors(); archetype._prepBindings(); - // forward parent properties to archetype - this._prepParentProperties(archetype, template); - // boilerplate code archetype._notifyPath = this._notifyPathImpl; archetype._scopeElementClass = this._scopeElementClassImpl; @@ -241,10 +241,12 @@ } } // Instance setup - this._extendTemplate(template, proto); if (template != this) { Polymer.Bind.prepareInstance(template); template._forwardParentProp = this._forwardParentProp.bind(this); + } + this._extendTemplate(template, proto); + if (template != this) { template._pathEffector = this._pathEffectorTemplate.bind(this); } } @@ -259,7 +261,7 @@ _createHostPropEffector: function(prop) { var prefix = this._parentPropPrefix; return function(source, value) { - this.dataHost[prefix + prop] = value; + this.dataHost._templatized[prefix + prop] = value; }; }, @@ -299,7 +301,7 @@ // Call extension point for Templatizer sub-classes dataHost._forwardInstancePath.call(dataHost, this, path, value); if (root in dataHost._parentProps) { - dataHost.notifyPath(dataHost._parentPropPrefix + path, value); + dataHost._templatized.notifyPath(dataHost._parentPropPrefix + path, value); } }, diff --git a/src/standard/notify-path.html b/src/standard/notify-path.html index 0ec156a890..9ba2391af4 100644 --- a/src/standard/notify-path.html +++ b/src/standard/notify-path.html @@ -491,7 +491,9 @@ // Base or all in Bind. prepareModelNotifyPath: function(model) { this.mixin(model, { + fire: Polymer.Base.fire, notifyPath: Polymer.Base.notifyPath, + _EVENT_CHANGED: Polymer.Base._EVENT_CHANGED, _notifyPath: Polymer.Base._notifyPath, _pathEffector: Polymer.Base._pathEffector, _annotationPathEffect: Polymer.Base._annotationPathEffect, diff --git a/test/runner.html b/test/runner.html index 0d78dec54c..03dd0a8550 100644 --- a/test/runner.html +++ b/test/runner.html @@ -57,6 +57,7 @@ 'unit/styling-cross-scope-unknown-host.html', 'unit/custom-style.html', 'unit/dynamic-import.html', + 'unit/templatizer.html', 'unit/dom-repeat.html', 'unit/dom-if.html', 'unit/dom-bind.html', diff --git a/test/unit/templatizer-elements.html b/test/unit/templatizer-elements.html new file mode 100644 index 0000000000..e11d033f7d --- /dev/null +++ b/test/unit/templatizer-elements.html @@ -0,0 +1,221 @@ + + + + + + diff --git a/test/unit/templatizer.html b/test/unit/templatizer.html new file mode 100644 index 0000000000..ca5b1dabb6 --- /dev/null +++ b/test/unit/templatizer.html @@ -0,0 +1,241 @@ + + + + + + + + + + + + + + +