Skip to content

Commit

Permalink
Merge branch 'master' into effective-children
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Orvell committed Oct 9, 2015
2 parents b40060a + d09c597 commit d021039
Show file tree
Hide file tree
Showing 23 changed files with 901 additions and 94 deletions.
37 changes: 37 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,42 @@
# Change Log

##[v1.1.5](https://github.com/Polymer/polymer/tree/v1.1.5) (2015-10-08)
- Simplify ([commit](https://github.com/Polymer/polymer/commit/79dfe1f))

- Clean up templatizer _pathEffectorImpl. ([commit](https://github.com/Polymer/polymer/commit/1a89bcf))

- Add issue link. ([commit](https://github.com/Polymer/polymer/commit/e4c2433))

- Missing var keyword ([commit](https://github.com/Polymer/polymer/commit/45fcbcf))

- Make sure we only actually call _listen once ([commit](https://github.com/Polymer/polymer/commit/837e9b8))

- Add templatizer tests. Fix issues from tests. ([commit](https://github.com/Polymer/polymer/commit/2d97cd7))

- Use 'value' in place of 'object' when referring to detail. ([commit](https://github.com/Polymer/polymer/commit/f17be35))

- Allow any type, not just objects, as the detail for fire. ([commit](https://github.com/Polymer/polymer/commit/ec59f57))

- Make model param of stamp method optional. ([commit](https://github.com/Polymer/polymer/commit/a2e1e64))

- add test to ensure unlisten events do not fire ([commit](https://github.com/Polymer/polymer/commit/bf2f694))

- add tests ([commit](https://github.com/Polymer/polymer/commit/900d82b))

- Only one real listener per `listen` call ([commit](https://github.com/Polymer/polymer/commit/8bd380a))

- add util method for shadow children ([commit](https://github.com/Polymer/polymer/commit/1e9110a))

- Add notify-path API to templatized template. Fixes #2505. ([commit](https://github.com/Polymer/polymer/commit/2e086fe))

- Parent property values should come from template. Fixes #2504. ([commit](https://github.com/Polymer/polymer/commit/23c883b))

- Added note about including a clear repro case. ([commit](https://github.com/Polymer/polymer/commit/e18f009))

- added request to submit an issue before sending a PR ([commit](https://github.com/Polymer/polymer/commit/6ed836f))

- update CHANGELOG to 1.1.4 ([commit](https://github.com/Polymer/polymer/commit/c2b7c31))

##[v1.1.4](https://github.com/Polymer/polymer/tree/v1.1.4) (2015-09-25)
- :memo: Update description ([commit](https://github.com/Polymer/polymer/commit/6afb8be))

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "polymer",
"version": "1.1.4",
"version": "1.1.5",
"main": [
"polymer.html"
],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Polymer",
"version": "1.1.4",
"version": "1.1.5",
"description": "The Polymer library makes it easy to create your own web components. Give your element some markup and properties, and then use it on a site. Polymer provides features like dynamic templates and data binding to reduce the amount of boilerplate you need to write",
"main": "polymer.html",
"directories": {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/bind/accessors.html
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@
return function(e, target) {
if (!bogusTest(e, target)) {
if (e.detail && e.detail.path) {
this.notifyPath(this._fixPath(path, property, e.detail.path),
this._notifyPath(this._fixPath(path, property, e.detail.path),
e.detail.value);
} else {
var value = target[property];
Expand Down
4 changes: 2 additions & 2 deletions src/lib/bind/effects.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

_annotationEffect: function(source, value, effect) {
if (source != effect.value) {
value = this.get(effect.value);
value = this._get(effect.value);
this.__data__[effect.value] = value;
}
var calc = effect.negate ? !value : value;
Expand Down Expand Up @@ -115,7 +115,7 @@
if (arg.literal) {
v = arg.value;
} else if (arg.structured) {
v = Polymer.Base.get(name, model);
v = Polymer.Base._get(name, model);
} else {
v = model[name];
}
Expand Down
24 changes: 20 additions & 4 deletions src/lib/collection.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@
} else {
this.pmap[item] = key;
}
return key;
return '#' + key;
},

removeKey: function(key) {
key = this._parseKey(key);
this._removeFromMap(this.store[key]);
delete this.store[key];
},
Expand All @@ -69,18 +70,32 @@
},

getKey: function(item) {
var key;
if (item && typeof item == 'object') {
return this.omap.get(item);
key = this.omap.get(item);
} else {
return this.pmap[item];
key = this.pmap[item];
}
if (key != undefined) {
return '#' + key;
}
},

getKeys: function() {
return Object.keys(this.store);
return Object.keys(this.store).map(function(key) {
return '#' + key;
});
},

_parseKey: function(key) {
if (key[0] == '#') {
return key.slice(1);
}
throw new Error('unexpected key ' + key);
},

setItem: function(key, item) {
key = this._parseKey(key);
var old = this.store[key];
if (old) {
this._removeFromMap(old);
Expand All @@ -94,6 +109,7 @@
},

getItem: function(key) {
key = this._parseKey(key);
return this.store[key];
},

Expand Down
3 changes: 2 additions & 1 deletion src/lib/experimental/observe-js-behavior.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
},

_removeObserveJsObserver: function(object, path) {
var obs = this._observeJsStatic.observerMap.get(object);
var el = obs.elements[this._observeJsId];
if (--el.paths[path] === 0) {
delete el.paths[path];
Expand Down Expand Up @@ -171,4 +172,4 @@
// Poll observe-js all the time
setInterval(Platform.performMicrotaskCheckpoint, 125);

</script>
</script>
3 changes: 2 additions & 1 deletion src/lib/template/array-selector.html
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
}
} else {
this.unlinkPaths('selected');
this.unlinkPaths('selectedItem');
}
// Initialize selection
if (this.multi) {
Expand Down Expand Up @@ -197,7 +198,7 @@
}
} else {
this.push('selected', item);
skey = this._selectedColl.getKey(item);
var skey = this._selectedColl.getKey(item);
this.linkPaths('selected.' + skey, 'items.' + key);
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/template/dom-if.html
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
// notifying parent.<path> path change on each row
_forwardParentPath: function(path, value) {
if (this._instance) {
this._instance.notifyPath(path, value, true);
this._instance._notifyPath(path, value, true);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/lib/template/dom-repeat.html
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@
// for notifying items.<key-for-inst>.<path> change up to host
_forwardInstancePath: function(inst, path, value) {
if (path.indexOf(this.as + '.') === 0) {
this.notifyPath('items.' + inst.__key__ + '.' +
this._notifyPath('items.' + inst.__key__ + '.' +
path.slice(this.as.length + 1), value);
}
},
Expand All @@ -624,7 +624,7 @@
// notifying parent path change on each inst
_forwardParentPath: function(path, value) {
this._instances.forEach(function(inst) {
inst.notifyPath(path, value, true);
inst._notifyPath(path, value, true);
}, this);
},

Expand All @@ -639,7 +639,7 @@
if (inst) {
if (dot >= 0) {
path = this.as + '.' + path.substring(dot+1);
inst.notifyPath(path, value, true);
inst._notifyPath(path, value, true);
} else {
inst.__setProperty(this.as, value, true);
}
Expand Down
30 changes: 17 additions & 13 deletions src/lib/template/templatizer.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
* @param {HTMLTemplateElement} template The template to process.
*/
templatize: function(template) {
this._templatized = template;
// TODO(sjmiles): supply _alternate_ content reference missing from root
// templates (not nested). `_content` exists to provide content sharing
// for nested templates.
Expand All @@ -108,17 +109,17 @@
// 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._notifyPathUp = this._notifyPathUpImpl;
archetype._scopeElementClass = this._scopeElementClassImpl;
archetype.listen = this._listenImpl;
archetype._showHideChildren = this._showHideChildrenImpl;
Expand Down Expand Up @@ -223,6 +224,7 @@
// assume that the template is not a Poylmer.Base, so prep it
// for binding
Polymer.Bind.prepareModel(proto);
Polymer.Base.prepareModelNotifyPath(proto);
}
// Create accessors for each parent prop that forward the property
// to template instances through abstract _forwardParentProp API
Expand All @@ -241,10 +243,10 @@
// Instance setup
if (template != this) {
Polymer.Bind.prepareInstance(template);
template._forwardParentProp =
this._forwardParentProp.bind(this);
template._forwardParentProp = this._forwardParentProp.bind(this);
}
this._extendTemplate(template, proto);
template._pathEffector = this._pathEffectorImpl.bind(this);
}
},

Expand All @@ -257,7 +259,7 @@
_createHostPropEffector: function(prop) {
var prefix = this._parentPropPrefix;
return function(source, value) {
this.dataHost[prefix + prop] = value;
this.dataHost._templatized[prefix + prop] = value;
};
},

Expand Down Expand Up @@ -290,25 +292,26 @@
// _forwardParentPath: function(path, value) { },
// _forwardParentProp: function(prop, value) { },

_notifyPathImpl: function(path, value) {
_notifyPathUpImpl: function(path, value) {
var dataHost = this.dataHost;
var dot = path.indexOf('.');
var root = dot < 0 ? path : path.slice(0, dot);
// 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);
}
},

// Overrides Base notify-path module
_pathEffector: function(path, value, fromAbove) {
_pathEffectorImpl: function(path, value, fromAbove) {
if (this._forwardParentPath) {
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) {
Expand Down Expand Up @@ -383,8 +386,9 @@
stamp: function(model) {
model = model || {};
if (this._parentProps) {
var templatized = this._templatized;
for (var prop in this._parentProps) {
model[prop] = this[this._parentPropPrefix + prop];
model[prop] = templatized[this._parentPropPrefix + prop];
}
}
return new this.ctor(model, this);
Expand Down
2 changes: 1 addition & 1 deletion src/standard/configure.html
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
// seeding configuration only
if (node._configValue) {
var value = (p === x.effect.value) ? config[p] :
this.get(x.effect.value, config);
this._get(x.effect.value, config);
node._configValue(x.effect.name, value);
}
}
Expand Down
16 changes: 14 additions & 2 deletions src/standard/events.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,17 @@
* @param {string} methodName Name of handler method on `this` to call.
*/
listen: function(node, eventName, methodName) {
this._listen(node, eventName,
this._createEventHandler(node, eventName, methodName));
var handler = this._recallEventHandler(this, eventName, node, methodName);
// reuse cache'd handler
if (!handler) {
handler = this._createEventHandler(node, eventName, methodName);
}
// don't call _listen if we are already listening
if (handler._listening) {
return;
}
this._listen(node, eventName, handler);
handler._listening = true;
},

_boundListenerKey: function(eventName, methodName) {
Expand Down Expand Up @@ -125,6 +134,7 @@
methodName + '` not defined'));
}
};
handler._listening = false;
this._recordEventHandler(host, eventName, node, methodName, handler);
return handler;
},
Expand All @@ -140,9 +150,11 @@
anymore.
*/
unlisten: function(node, eventName, methodName) {
// leave handler in map for cache purposes
var handler = this._recallEventHandler(this, eventName, node, methodName);
if (handler) {
this._unlisten(node, eventName, handler);
handler._listening = false;
}
},

Expand Down
Loading

0 comments on commit d021039

Please sign in to comment.