update polymer

This commit is contained in:
Luke Pulverenti 2015-10-08 21:55:36 -04:00
parent 45250e4540
commit 78975c306d
3 changed files with 96 additions and 22 deletions

View file

@ -576,7 +576,7 @@ debouncer.stop();
} }
} }
}); });
Polymer.version = '1.1.4'; Polymer.version = '1.1.5';
Polymer.Base._addFeature({ Polymer.Base._addFeature({
_registerFeatures: function () { _registerFeatures: function () {
this._prepIs(); this._prepIs();

View file

@ -357,7 +357,15 @@ this.listen(node, name, listeners[key]);
} }
}, },
listen: function (node, eventName, methodName) { listen: function (node, eventName, methodName) {
this._listen(node, eventName, this._createEventHandler(node, eventName, methodName)); var handler = this._recallEventHandler(this, eventName, node, methodName);
if (!handler) {
handler = this._createEventHandler(node, eventName, methodName);
}
if (handler._listening) {
return;
}
this._listen(node, eventName, handler);
handler._listening = true;
}, },
_boundListenerKey: function (eventName, methodName) { _boundListenerKey: function (eventName, methodName) {
return eventName + ':' + methodName; return eventName + ':' + methodName;
@ -396,6 +404,7 @@ host[methodName](e, e.detail);
host._warn(host._logf('_createEventHandler', 'listener method `' + methodName + '` not defined')); host._warn(host._logf('_createEventHandler', 'listener method `' + methodName + '` not defined'));
} }
}; };
handler._listening = false;
this._recordEventHandler(host, eventName, node, methodName, handler); this._recordEventHandler(host, eventName, node, methodName, handler);
return handler; return handler;
}, },
@ -403,6 +412,7 @@ unlisten: function (node, eventName, methodName) {
var handler = this._recallEventHandler(this, eventName, node, methodName); var handler = this._recallEventHandler(this, eventName, node, methodName);
if (handler) { if (handler) {
this._unlisten(node, eventName, handler); this._unlisten(node, eventName, handler);
handler._listening = false;
} }
}, },
_listen: function (node, eventName, handler) { _listen: function (node, eventName, handler) {
@ -641,7 +651,7 @@ prevent = dy > dx;
prevent = dx > dy; prevent = dx > dy;
} }
if (prevent) { if (prevent) {
//ev.preventDefault(); ev.preventDefault();
} else { } else {
Gestures.prevent('track'); Gestures.prevent('track');
} }
@ -1250,6 +1260,12 @@ elt[n] = props[n];
} }
} }
return elt; return elt;
},
isLightDescendant: function (node) {
return this.contains(node) && Polymer.dom(this).getOwnerRoot() === Polymer.dom(node).getOwnerRoot();
},
isLocalDescendant: function (node) {
return this.root === Polymer.dom(node).getOwnerRoot();
} }
}); });
Polymer.Bind = { Polymer.Bind = {
@ -2051,6 +2067,22 @@ if (args.length) {
this._notifySplice(array, path, 0, args.length, []); this._notifySplice(array, path, 0, args.length, []);
} }
return ret; return ret;
},
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,
_complexObserverPathEffect: Polymer.Base._complexObserverPathEffect,
_annotatedComputationPathEffect: Polymer.Base._annotatedComputationPathEffect,
_computePathEffect: Polymer.Base._computePathEffect,
_modelForPath: Polymer.Base._modelForPath,
_pathMatchesEffect: Polymer.Base._pathMatchesEffect,
_notifyBoundPaths: Polymer.Base._notifyBoundPaths
});
} }
}); });
}()); }());
@ -3258,6 +3290,7 @@ properties: { __hideTemplateChildren__: { observer: '_showHideChildren' } },
_instanceProps: Polymer.nob, _instanceProps: Polymer.nob,
_parentPropPrefix: '_parent_', _parentPropPrefix: '_parent_',
templatize: function (template) { templatize: function (template) {
this._templatized = template;
if (!template._content) { if (!template._content) {
template._content = template.content; template._content = template.content;
} }
@ -3268,11 +3301,11 @@ return;
} }
var archetype = Object.create(Polymer.Base); var archetype = Object.create(Polymer.Base);
this._customPrepAnnotations(archetype, template); this._customPrepAnnotations(archetype, template);
this._prepParentProperties(archetype, template);
archetype._prepEffects(); archetype._prepEffects();
this._customPrepEffects(archetype); this._customPrepEffects(archetype);
archetype._prepBehaviors(); archetype._prepBehaviors();
archetype._prepBindings(); archetype._prepBindings();
this._prepParentProperties(archetype, template);
archetype._notifyPath = this._notifyPathImpl; archetype._notifyPath = this._notifyPathImpl;
archetype._scopeElementClass = this._scopeElementClassImpl; archetype._scopeElementClass = this._scopeElementClassImpl;
archetype.listen = this._listenImpl; archetype.listen = this._listenImpl;
@ -3355,6 +3388,7 @@ delete parentProps[prop];
proto = archetype._parentPropProto = Object.create(null); proto = archetype._parentPropProto = Object.create(null);
if (template != this) { if (template != this) {
Polymer.Bind.prepareModel(proto); Polymer.Bind.prepareModel(proto);
Polymer.Base.prepareModelNotifyPath(proto);
} }
for (prop in parentProps) { for (prop in parentProps) {
var parentProp = this._parentPropPrefix + prop; var parentProp = this._parentPropPrefix + prop;
@ -3373,6 +3407,7 @@ Polymer.Bind.prepareInstance(template);
template._forwardParentProp = this._forwardParentProp.bind(this); template._forwardParentProp = this._forwardParentProp.bind(this);
} }
this._extendTemplate(template, proto); this._extendTemplate(template, proto);
template._pathEffector = this._pathEffectorImpl.bind(this);
} }
}, },
_createForwardPropEffector: function (prop) { _createForwardPropEffector: function (prop) {
@ -3383,7 +3418,7 @@ this._forwardParentProp(prop, value);
_createHostPropEffector: function (prop) { _createHostPropEffector: function (prop) {
var prefix = this._parentPropPrefix; var prefix = this._parentPropPrefix;
return function (source, value) { return function (source, value) {
this.dataHost[prefix + prop] = value; this.dataHost._templatized[prefix + prop] = value;
}; };
}, },
_createInstancePropEffector: function (prop) { _createInstancePropEffector: function (prop) {
@ -3415,16 +3450,17 @@ var dot = path.indexOf('.');
var root = dot < 0 ? path : path.slice(0, dot); var root = dot < 0 ? path : path.slice(0, dot);
dataHost._forwardInstancePath.call(dataHost, this, path, value); dataHost._forwardInstancePath.call(dataHost, this, path, value);
if (root in dataHost._parentProps) { if (root in dataHost._parentProps) {
dataHost.notifyPath(dataHost._parentPropPrefix + path, value); dataHost._templatized.notifyPath(dataHost._parentPropPrefix + path, value);
} }
}, },
_pathEffector: function (path, value, fromAbove) { _pathEffectorImpl: function (path, value, fromAbove) {
if (this._forwardParentPath) { if (this._forwardParentPath) {
if (path.indexOf(this._parentPropPrefix) === 0) { if (path.indexOf(this._parentPropPrefix) === 0) {
this._forwardParentPath(path.substring(8), value); var subPath = path.substring(this._parentPropPrefix.length);
this._forwardParentPath(subPath, value);
} }
} }
Polymer.Base._pathEffector.apply(this, arguments); Polymer.Base._pathEffector.call(this._templatized, path, value, fromAbove);
}, },
_constructorImpl: function (model, host) { _constructorImpl: function (model, host) {
this._rootDataHost = host._getRootDataHost(); this._rootDataHost = host._getRootDataHost();
@ -3467,8 +3503,9 @@ return host._scopeElementClass(node, value);
stamp: function (model) { stamp: function (model) {
model = model || {}; model = model || {};
if (this._parentProps) { if (this._parentProps) {
var templatized = this._templatized;
for (var prop in this._parentProps) { for (var prop in this._parentProps) {
model[prop] = this[this._parentPropPrefix + prop]; model[prop] = templatized[this._parentPropPrefix + prop];
} }
} }
return new this.ctor(model, this); return new this.ctor(model, this);
@ -4076,7 +4113,7 @@ this.deselect(item);
} }
} else { } else {
this.push('selected', item); this.push('selected', item);
skey = this._selectedColl.getKey(item); var skey = this._selectedColl.getKey(item);
this.linkPaths('selected.' + skey, 'items.' + key); this.linkPaths('selected.' + skey, 'items.' + key);
} }
} else { } else {

View file

@ -592,7 +592,7 @@ debouncer.stop();
} }
} }
}); });
Polymer.version = '1.1.4'; Polymer.version = '1.1.5';
Polymer.Base._addFeature({ Polymer.Base._addFeature({
_registerFeatures: function () { _registerFeatures: function () {
this._prepIs(); this._prepIs();
@ -2471,7 +2471,15 @@ this.listen(node, name, listeners[key]);
} }
}, },
listen: function (node, eventName, methodName) { listen: function (node, eventName, methodName) {
this._listen(node, eventName, this._createEventHandler(node, eventName, methodName)); var handler = this._recallEventHandler(this, eventName, node, methodName);
if (!handler) {
handler = this._createEventHandler(node, eventName, methodName);
}
if (handler._listening) {
return;
}
this._listen(node, eventName, handler);
handler._listening = true;
}, },
_boundListenerKey: function (eventName, methodName) { _boundListenerKey: function (eventName, methodName) {
return eventName + ':' + methodName; return eventName + ':' + methodName;
@ -2510,6 +2518,7 @@ host[methodName](e, e.detail);
host._warn(host._logf('_createEventHandler', 'listener method `' + methodName + '` not defined')); host._warn(host._logf('_createEventHandler', 'listener method `' + methodName + '` not defined'));
} }
}; };
handler._listening = false;
this._recordEventHandler(host, eventName, node, methodName, handler); this._recordEventHandler(host, eventName, node, methodName, handler);
return handler; return handler;
}, },
@ -2517,6 +2526,7 @@ unlisten: function (node, eventName, methodName) {
var handler = this._recallEventHandler(this, eventName, node, methodName); var handler = this._recallEventHandler(this, eventName, node, methodName);
if (handler) { if (handler) {
this._unlisten(node, eventName, handler); this._unlisten(node, eventName, handler);
handler._listening = false;
} }
}, },
_listen: function (node, eventName, handler) { _listen: function (node, eventName, handler) {
@ -2755,7 +2765,7 @@ prevent = dy > dx;
prevent = dx > dy; prevent = dx > dy;
} }
if (prevent) { if (prevent) {
//ev.preventDefault(); ev.preventDefault();
} else { } else {
Gestures.prevent('track'); Gestures.prevent('track');
} }
@ -3364,6 +3374,12 @@ elt[n] = props[n];
} }
} }
return elt; return elt;
},
isLightDescendant: function (node) {
return this.contains(node) && Polymer.dom(this).getOwnerRoot() === Polymer.dom(node).getOwnerRoot();
},
isLocalDescendant: function (node) {
return this.root === Polymer.dom(node).getOwnerRoot();
} }
}); });
Polymer.Bind = { Polymer.Bind = {
@ -4165,6 +4181,22 @@ if (args.length) {
this._notifySplice(array, path, 0, args.length, []); this._notifySplice(array, path, 0, args.length, []);
} }
return ret; return ret;
},
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,
_complexObserverPathEffect: Polymer.Base._complexObserverPathEffect,
_annotatedComputationPathEffect: Polymer.Base._annotatedComputationPathEffect,
_computePathEffect: Polymer.Base._computePathEffect,
_modelForPath: Polymer.Base._modelForPath,
_pathMatchesEffect: Polymer.Base._pathMatchesEffect,
_notifyBoundPaths: Polymer.Base._notifyBoundPaths
});
} }
}); });
}()); }());
@ -5372,6 +5404,7 @@ properties: { __hideTemplateChildren__: { observer: '_showHideChildren' } },
_instanceProps: Polymer.nob, _instanceProps: Polymer.nob,
_parentPropPrefix: '_parent_', _parentPropPrefix: '_parent_',
templatize: function (template) { templatize: function (template) {
this._templatized = template;
if (!template._content) { if (!template._content) {
template._content = template.content; template._content = template.content;
} }
@ -5382,11 +5415,11 @@ return;
} }
var archetype = Object.create(Polymer.Base); var archetype = Object.create(Polymer.Base);
this._customPrepAnnotations(archetype, template); this._customPrepAnnotations(archetype, template);
this._prepParentProperties(archetype, template);
archetype._prepEffects(); archetype._prepEffects();
this._customPrepEffects(archetype); this._customPrepEffects(archetype);
archetype._prepBehaviors(); archetype._prepBehaviors();
archetype._prepBindings(); archetype._prepBindings();
this._prepParentProperties(archetype, template);
archetype._notifyPath = this._notifyPathImpl; archetype._notifyPath = this._notifyPathImpl;
archetype._scopeElementClass = this._scopeElementClassImpl; archetype._scopeElementClass = this._scopeElementClassImpl;
archetype.listen = this._listenImpl; archetype.listen = this._listenImpl;
@ -5469,6 +5502,7 @@ delete parentProps[prop];
proto = archetype._parentPropProto = Object.create(null); proto = archetype._parentPropProto = Object.create(null);
if (template != this) { if (template != this) {
Polymer.Bind.prepareModel(proto); Polymer.Bind.prepareModel(proto);
Polymer.Base.prepareModelNotifyPath(proto);
} }
for (prop in parentProps) { for (prop in parentProps) {
var parentProp = this._parentPropPrefix + prop; var parentProp = this._parentPropPrefix + prop;
@ -5487,6 +5521,7 @@ Polymer.Bind.prepareInstance(template);
template._forwardParentProp = this._forwardParentProp.bind(this); template._forwardParentProp = this._forwardParentProp.bind(this);
} }
this._extendTemplate(template, proto); this._extendTemplate(template, proto);
template._pathEffector = this._pathEffectorImpl.bind(this);
} }
}, },
_createForwardPropEffector: function (prop) { _createForwardPropEffector: function (prop) {
@ -5497,7 +5532,7 @@ this._forwardParentProp(prop, value);
_createHostPropEffector: function (prop) { _createHostPropEffector: function (prop) {
var prefix = this._parentPropPrefix; var prefix = this._parentPropPrefix;
return function (source, value) { return function (source, value) {
this.dataHost[prefix + prop] = value; this.dataHost._templatized[prefix + prop] = value;
}; };
}, },
_createInstancePropEffector: function (prop) { _createInstancePropEffector: function (prop) {
@ -5529,16 +5564,17 @@ var dot = path.indexOf('.');
var root = dot < 0 ? path : path.slice(0, dot); var root = dot < 0 ? path : path.slice(0, dot);
dataHost._forwardInstancePath.call(dataHost, this, path, value); dataHost._forwardInstancePath.call(dataHost, this, path, value);
if (root in dataHost._parentProps) { if (root in dataHost._parentProps) {
dataHost.notifyPath(dataHost._parentPropPrefix + path, value); dataHost._templatized.notifyPath(dataHost._parentPropPrefix + path, value);
} }
}, },
_pathEffector: function (path, value, fromAbove) { _pathEffectorImpl: function (path, value, fromAbove) {
if (this._forwardParentPath) { if (this._forwardParentPath) {
if (path.indexOf(this._parentPropPrefix) === 0) { if (path.indexOf(this._parentPropPrefix) === 0) {
this._forwardParentPath(path.substring(8), value); var subPath = path.substring(this._parentPropPrefix.length);
this._forwardParentPath(subPath, value);
} }
} }
Polymer.Base._pathEffector.apply(this, arguments); Polymer.Base._pathEffector.call(this._templatized, path, value, fromAbove);
}, },
_constructorImpl: function (model, host) { _constructorImpl: function (model, host) {
this._rootDataHost = host._getRootDataHost(); this._rootDataHost = host._getRootDataHost();
@ -5581,8 +5617,9 @@ return host._scopeElementClass(node, value);
stamp: function (model) { stamp: function (model) {
model = model || {}; model = model || {};
if (this._parentProps) { if (this._parentProps) {
var templatized = this._templatized;
for (var prop in this._parentProps) { for (var prop in this._parentProps) {
model[prop] = this[this._parentPropPrefix + prop]; model[prop] = templatized[this._parentPropPrefix + prop];
} }
} }
return new this.ctor(model, this); return new this.ctor(model, this);
@ -6190,7 +6227,7 @@ this.deselect(item);
} }
} else { } else {
this.push('selected', item); this.push('selected', item);
skey = this._selectedColl.getKey(item); var skey = this._selectedColl.getKey(item);
this.linkPaths('selected.' + skey, 'items.' + key); this.linkPaths('selected.' + skey, 'items.' + key);
} }
} else { } else {