Skip to content

Commit 2e086fe

Browse files
committed
Add notify-path API to templatized template. Fixes #2505.
1 parent 23c883b commit 2e086fe

2 files changed

Lines changed: 32 additions & 3 deletions

File tree

‎src/lib/template/templatizer.html‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@
224224
// assume that the template is not a Poylmer.Base, so prep it
225225
// for binding
226226
Polymer.Bind.prepareModel(proto);
227+
Polymer.Base.prepareModelNotifyPath(proto);
227228
}
228229
// Create accessors for each parent prop that forward the property
229230
// to template instances through abstract _forwardParentProp API
@@ -240,12 +241,12 @@
240241
}
241242
}
242243
// Instance setup
244+
this._extendTemplate(template, proto);
243245
if (template != this) {
244246
Polymer.Bind.prepareInstance(template);
245-
template._forwardParentProp =
246-
this._forwardParentProp.bind(this);
247+
template._forwardParentProp = this._forwardParentProp.bind(this);
248+
template._pathEffector = this._pathEffectorTemplate.bind(this);
247249
}
248-
this._extendTemplate(template, proto);
249250
}
250251
},
251252

@@ -312,6 +313,15 @@
312313
Polymer.Base._pathEffector.apply(this, arguments);
313314
},
314315

316+
// Overrides Base notify-path module (for non-PE templates)
317+
_pathEffectorTemplate: function(path, value, fromAbove) {
318+
if (this._forwardParentPath) {
319+
if (path.indexOf(this._parentPropPrefix) === 0) {
320+
this._forwardParentPath(path.substring(8), value);
321+
}
322+
}
323+
},
324+
315325
_constructorImpl: function(model, host) {
316326
this._rootDataHost = host._getRootDataHost();
317327
this._setupConfigure(model);

‎src/standard/notify-path.html‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,25 @@
483483
this._notifySplice(array, path, 0, args.length, []);
484484
}
485485
return ret;
486+
},
487+
488+
// TODO(kschaaf): This is the path analogue to Polymer.Bind.prepareModel,
489+
// which provides API for path-based notification on elements with property
490+
// effects; this should be re-factored along with the Bind lib, either all on
491+
// Base or all in Bind.
492+
prepareModelNotifyPath: function(model) {
493+
this.mixin(model, {
494+
notifyPath: Polymer.Base.notifyPath,
495+
_notifyPath: Polymer.Base._notifyPath,
496+
_pathEffector: Polymer.Base._pathEffector,
497+
_annotationPathEffect: Polymer.Base._annotationPathEffect,
498+
_complexObserverPathEffect: Polymer.Base._complexObserverPathEffect,
499+
_annotatedComputationPathEffect: Polymer.Base._annotatedComputationPathEffect,
500+
_computePathEffect: Polymer.Base._computePathEffect,
501+
_modelForPath: Polymer.Base._modelForPath,
502+
_pathMatchesEffect: Polymer.Base._pathMatchesEffect,
503+
_notifyBoundPaths: Polymer.Base._notifyBoundPaths
504+
});
486505
}
487506

488507
});

0 commit comments

Comments
 (0)