Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.8 api scrub #1440

Merged
merged 4 commits into from
Apr 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions src/lib/annotations/annotations.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<link rel="import" href="../module.html">
<link rel="import" href="../case-map.html">
<link rel="import" href="../case-map.html">

<script>
/**
* Scans a template to produce an annotation list that that associates
* metadata culled from markup with tree locations
* metadata culled from markup with tree locations
* metadata and information to associate the metadata with nodes in an instance.
*
* Supported expressions include:
Expand All @@ -35,7 +35,7 @@
* associated with these expressions, it only captures the data.
*
* Generated data-structure:
*
*
* [
* {
* id: '<id>',
Expand All @@ -59,7 +59,7 @@
* },
* ...
* ]
*
*
* @class Template feature
*/

Expand All @@ -75,7 +75,7 @@
//
parseAnnotations: function(template) {
var list = [];
var content = template._content || template.content;
var content = template._content || template.content;
this._parseNodeAnnotations(content, list);
return list;
},
Expand Down Expand Up @@ -121,7 +121,7 @@
this._parseNodeAttributeAnnotations(element, annote, list);
// TODO(sorvell): ad hoc callback for doing work on elements while
// leveraging annotator's tree walk.
// Consider adding an node callback registry and moving specific
// Consider adding an node callback registry and moving specific
// processing out of this module.
if (this.prepElement) {
this.prepElement(element);
Expand All @@ -134,7 +134,7 @@
},

// add annotations gleaned from children of `root` to `list`, `root`'s
// `annote` is supplied as it is the annote.parent of added annotations
// `annote` is supplied as it is the annote.parent of added annotations
_parseChildNodesAnnotations: function(root, annote, list, callback) {
if (root.firstChild) {
for (var i=0, node=root.firstChild; node; node=node.nextSibling, i++){
Expand Down Expand Up @@ -186,7 +186,7 @@
});
}
// TODO(sjmiles): using `nar` to avoid unnecessary allocation;
// in general the handling of these arrays needs some cleanup
// in general the handling of these arrays needs some cleanup
// in this module
list.push({
bindings: bindings,
Expand All @@ -202,7 +202,7 @@
// of maps listing the properties of parent templates required at
// each level. Each outer template merges inner _parentPropChains to
// propagate inner parent property needs to outer templates.
// The top-level parent props from the chain (corresponding to this
// The top-level parent props from the chain (corresponding to this
// template) are stored in content._parentProps.
_discoverTemplateParentProps: function(content) {
var chain = content._parentPropChain = [];
Expand All @@ -224,7 +224,7 @@
for (var i=1; i<tpp.length; i++) {
if (tpp[i]) {
var pp = chain[i-1] || (chain[i-1] = {});
Polymer.Base.simpleMixin(pp, tpp[i]);
Polymer.Base.mixin(pp, tpp[i]);
}
}
}
Expand All @@ -234,7 +234,7 @@
},

// add annotation data from attributes to the `annotation` for node `node`
// TODO(sjmiles): the distinction between an `annotation` and
// TODO(sjmiles): the distinction between an `annotation` and
// `annotation data` is not as clear as it could be
// Walk attributes backwards, since removeAttribute can be vetoed by
// IE in certain cases (e.g. <input value="foo">), resulting in the
Expand Down Expand Up @@ -291,8 +291,8 @@
}
// Remove annotation
node.removeAttribute(n);
// Case hackery: attributes are lower-case, but bind targets
// (properties) are case sensitive. Gambit is to map dash-case to
// Case hackery: attributes are lower-case, but bind targets
// (properties) are case sensitive. Gambit is to map dash-case to
// camel-case: `foo-bar` becomes `fooBar`.
// Attribute bindings are excepted.
if (kind === 'property') {
Expand All @@ -318,10 +318,10 @@

findAnnotatedNode: function(root, annote) {
// recursively ascend tree until we hit root
var parent = annote.parent &&
var parent = annote.parent &&
Polymer.Annotations.findAnnotatedNode(root, annote.parent);
// unwind the stack, returning the indexed node at each level
return !parent ? root :
return !parent ? root :
Polymer.Annotations._localSubTree(parent, root)[annote.index];
}

Expand Down
6 changes: 2 additions & 4 deletions src/lib/bind/accessors.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
_effectEffects: function(property, value, effects, old) {
effects.forEach(function(fx) {
//console.log(fx);
var fn = Polymer.Bind[fx.kind + 'Effect'];
var fn = Polymer.Bind['_' + fx.kind + 'Effect'];
if (fn) {
fn.call(this, property, value, fx.effect, old);
}
Expand Down Expand Up @@ -151,9 +151,7 @@
// ReadOnly properties have a private setter only
// TODO(kschaaf): Per current Bind factoring, we shouldn't
// be interrogating the prototype here
if (model.isReadOnlyProperty && model.isReadOnlyProperty(property)) {
//model['_' + property + 'Setter'] = setter;
//model['_set_' + property] = setter;
if (model.getPropertyInfo && model.getPropertyInfo(property).readOnly) {
model['_set' + this.upper(property)] = setter;
} else {
defun.set = setter;
Expand Down
18 changes: 9 additions & 9 deletions src/lib/bind/effects.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
;
},

annotationEffect: function(source, value, effect) {
_annotationEffect: function(source, value, effect) {
if (source != effect.value) {
value = this.getPathValue(effect.value);
this._data[effect.value] = value;
Expand All @@ -29,42 +29,42 @@
return this._applyEffectValue(calc, effect);
},

reflectEffect: function(source) {
_reflectEffect: function(source) {
this.reflectPropertyToAttribute(source);
},

notifyEffect: function(source) {
_notifyEffect: function(source) {
this._notifyChange(source);
},

// Raw effect for extension; effect.function is an actual function
functionEffect: function(source, value, effect, old) {
_functionEffect: function(source, value, effect, old) {
effect.function.call(this, source, value, effect, old);
},

observerEffect: function(source, value, effect, old) {
_observerEffect: function(source, value, effect, old) {
this[effect.method](value, old);
},

complexObserverEffect: function(source, value, effect) {
_complexObserverEffect: function(source, value, effect) {
var args = Polymer.Bind._marshalArgs(this._data, effect, source, value);
if (args) {
this[effect.method].apply(this, args);
}
},

computeEffect: function(source, value, effect) {
_computeEffect: function(source, value, effect) {
var args = Polymer.Bind._marshalArgs(this._data, effect, source, value);
if (args) {
this[effect.property] = this[effect.method].apply(this, args);
}
},

annotatedComputationEffect: function(source, value, effect) {
_annotatedComputationEffect: function(source, value, effect) {
var args = Polymer.Bind._marshalArgs(this._data, effect, source, value);
if (args) {
var computedHost = this._rootDataHost || this;
var computedvalue =
var computedvalue =
computedHost[effect.method].apply(computedHost, args);
this._applyEffectValue(computedvalue, effect);
}
Expand Down
26 changes: 13 additions & 13 deletions src/lib/template/x-array-selector.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@
<div>Last name: <span>{{item.last}}</span></div>
<button on-click="toggleSelection">Select</button>
</template>

<x-array-selector id="selector" items="{{employees}}" selected="{{selected}}" multi toggle></x-array-selector>

<div> Selected employees: </div>
<template is="x-repeat" items="{{selected}}">
<div>First name: <span>{{item.first}}</span></div>
<div>Last name: <span>{{item.last}}</span></div>
</template>

</template>

<script>
Expand All @@ -59,14 +59,14 @@
</script>

</dom-module>
```
```
-->

<script>

Polymer({
is: 'x-array-selector',

properties: {

/**
Expand Down Expand Up @@ -100,15 +100,15 @@
*/
multi: Boolean
},

_itemsChanged: function() {
// Unbind previous selection
if (Array.isArray(this.selected)) {
for (var i=0; i<this.selected.length; i++) {
this.unbindPaths('selected.' + i);
this.unlinkPaths('selected.' + i);
}
} else {
this.unbindPaths('selected');
this.unlinkPaths('selected');
}
// Initialize selection
if (this.multi) {
Expand All @@ -131,12 +131,12 @@
var skey = scol.getKey(item);
this.selected.splice(sidx, 1);
// scol.remove(item);
this.unbindPaths('selected.' + skey);
this.unlinkPaths('selected.' + skey);
return true;
}
} else {
this.selected = null;
this.unbindPaths('selected');
this.unlinkPaths('selected');
}
},

Expand All @@ -156,18 +156,18 @@
this.deselect(item);
} else if (this.toggle) {
this.selected.push(item);
// this.bindPaths('selected.' + sidx, 'items.' + skey);
// this.linkPaths('selected.' + sidx, 'items.' + skey);
// skey = Polymer.Collection.get(this.selected).add(item);
this.async(function() {
skey = scol.getKey(item);
this.bindPaths('selected.' + skey, 'items.' + key);
this.linkPaths('selected.' + skey, 'items.' + key);
});
}
} else {
if (this.toggle && item == this.selected) {
this.deselect();
} else {
this.bindPaths('selected', 'items.' + key);
this.linkPaths('selected', 'items.' + key);
this.selected = item;
}
}
Expand Down
19 changes: 7 additions & 12 deletions src/micro/attributes.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@

_installHostAttributes: function(attributes) {
if (attributes) {
this.applyAttributes(this, attributes);
this._applyAttributes(this, attributes);
}
},

applyAttributes: function(node, attr$) {
_applyAttributes: function(node, attr$) {
for (var n in attr$) {
this.serializeValueToAttribute(attr$[n], n, this);
}
Expand All @@ -79,24 +79,19 @@

_takeAttributesToModel: function(model) {
for (var i=0, l=this.attributes.length; i<l; i++) {
var a = this.attributes[i];
var property = Polymer.CaseMap.dashToCamelCase(a.name);
var info = this.getPropertyInfo(property);
if (info || this._propertyEffects[property]) {
model[property] =
this.deserialize(a.value, info.type);
}
this.setAttributeToProperty(model, this.attributes[i].name);
}
},

setAttributeToProperty: function(model, attrName) {
// Don't deserialize back to property if currently reflecting
if (!this._serializing) {
var propName = Polymer.CaseMap.dashToCamelCase(attrName);
if (propName in this.properties) {
var type = this.getPropertyType(propName);
var info = this.getPropertyInfo(propName);
if (info.defined ||
(this._propertyEffects && this._propertyEffects[propName])) {
var val = this.getAttribute(attrName);
model[propName] = this.deserialize(val, type);
model[propName] = this.deserialize(val, info.type);
}
}
},
Expand Down
Loading