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 miceplay #1012

Merged
merged 8 commits into from
Dec 10, 2014
Merged
13 changes: 0 additions & 13 deletions data.html
Original file line number Diff line number Diff line change
@@ -1,13 +0,0 @@
<!--
@license
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<link rel="import" href="src/features/bind.html">
<link rel="import" href="src/features/annotations-bind.html">
<link rel="import" href="src/features/computed.html">
<link rel="import" href="src/features/bind-effects.html">
75 changes: 75 additions & 0 deletions polymer-core.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<!--
@license
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<link rel="import" href="src/polymer.html">
<link rel="import" href="src/features/log.html">
<link rel="import" href="src/features/constructor.html">
<link rel="import" href="src/features/extends.html">
<link rel="import" href="src/features/mixins.html">
<link rel="import" href="src/features/published.html">
<link rel="import" href="src/features/attributes.html">
<link rel="import" href="src/features/template.html">
<link rel="import" href="src/features/content.html">
<link rel="import" href="src/features/annotations.html">
<link rel="import" href="src/features/annotations-nodes.html">
<link rel="import" href="src/features/events.html">
<link rel="import" href="src/features/keys.html">
<link rel="import" href="src/features/annotations-events.html">
<link rel="import" href="src/features/utils.html">
<link rel="import" href="src/features/ready.html">

<link rel="import" href="src/layout.html">

<script>

// TODO(sjmiles): hack
Base.originalInitFeatures = Base.initFeatures;

Base.addFeature({

initFeatures: function() {
// TODO(sjmiles): hack to make sure this feature goes last
this.originalInitFeatures(this);
this.features();
},

features: function() {
this.defaultFeatures();
},

defaultFeatures: function() {
if (this._useContent) {
this.poolContent();
}
if (this._template) {
this.stampTemplate();
this._marshalNodeReferences();
this._marshalAnnotatedNodes();
this._setupAnnotatedListeners();
if (this._setupBindListeners) {
this._setupBindListeners();
}
}
this.listenListeners();
this.listenKeyPresses();
if (this._useContent) {
this.distributeContent();
}
this.takeAttributes();
}

});

Polymer.noFeatures = function() {
};

Polymer.defaultFeatures = Base.defaultFeatures;

</script>

13 changes: 13 additions & 0 deletions polymer-data.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!--
@license
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<link rel="import" href="src/data-features/bind.html">
<link rel="import" href="src/data-features/annotations-bind.html">
<link rel="import" href="src/data-features/computed.html">
<link rel="import" href="src/data-features/bind-effects.html">
64 changes: 2 additions & 62 deletions polymer.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,65 +7,5 @@
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<link rel="import" href="src/polymer.html">
<link rel="import" href="src/features/log.html">
<link rel="import" href="src/features/published.html">
<link rel="import" href="src/features/attributes.html">
<link rel="import" href="src/features/template.html">
<link rel="import" href="src/features/content.html">
<link rel="import" href="src/features/annotations.html">
<link rel="import" href="src/features/annotations-nodes.html">
<link rel="import" href="src/features/events.html">
<link rel="import" href="src/features/keys.html">
<link rel="import" href="src/features/annotations-events.html">
<link rel="import" href="src/features/utils.html">
<link rel="import" href="src/features/layout.html">
<link rel="import" href="src/features/ready.html">

<script>

// TODO(sjmiles): hack
Base.originalInitFeatures = Base.initFeatures;

Base.addFeature({

initFeatures: function() {
// TODO(sjmiles): hack to make sure this feature goes last
this.originalInitFeatures(this);
this.features();
},

features: function() {
this.defaultFeatures();
},

defaultFeatures: function() {
if (this._useContent) {
this.poolContent();
}
if (this._template) {
this.stampTemplate();
this._marshalNodeReferences();
this._marshalAnnotatedNodes();
this._setupAnnotatedListeners();
if (this._setupBindListeners) {
this._setupBindListeners();
}
}
this.listenListeners();
this.listenKeyPresses();
if (this._useContent) {
this.distributeContent();
}
this.takeAttributes();
}

});

Polymer.noFeatures = function() {
};

Polymer.defaultFeatures = Base.defaultFeatures;

</script>

<link rel="import" href="polymer-core.html">
<link rel="import" href="polymer-data.html">
2 changes: 2 additions & 0 deletions src/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
},

attachedCallback: function() {
this.isAttached = true;
// reserved for canonical behavior
this.attached();
},
Expand All @@ -76,6 +77,7 @@
},

detachedCallback: function() {
this.isAttached = false;
// reserved for canonical behavior
this.detached();
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<link rel="import" href="annotations.html">
<link rel="import" href="../features/annotations.html">

<script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@
// per prototype

register: function(prototype) {
prototype._bindListeners = [];
prototype._createBindings();
},

_createBindings: function() {
this._bindListeners = [];
var fx$ = this._propertyEffects;
if (fx$) {
//console.group(this.name);
Expand All @@ -76,14 +76,13 @@
},

_sortPropertyEffects: function(a, b) {
switch (a.kind) {
case 'compute':
return b.kind === 'compute' ? 0 : -1;
case 'notify':
return b.kind === 'notify' ? 0 : 1;
default:
return 0;
if (a.kind === 'compute' || b.kind === 'notify') {
return -1;
}
if (a.kind === 'notify' || b.kind === 'compute') {
return 1;
}
return 0;
},

_buildEffect: function(property, fx) {
Expand Down
File renamed without changes.
File renamed without changes.
76 changes: 76 additions & 0 deletions src/data/annotations-bind.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<!--
@license
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<link rel="import" href="annotations.html">

<script>

/*
* Parses the annotations list created by `annotations` features to perform
* declarative desugaring.
*
* Depends on `annotations` feature and `bind` feature.
*
* Two tasks are supported:
*
* - nodes with 'id' are described in a virtual annotation list at
* registration time. This list is then concretized per instance.
*
* - Simple mustache expressions consisting of a single property name
* in a `textContent` context are bound using `bind` features
* `bindMethod`. In this mode, the bound method is constructed at
* registration time, so marshaling is done done via the concretized
* `_nodes` at every access.
*
* TODO(sjmiles): ph3ar general confusion between registration and
* instance time tasks. Is there a cleaner way to disambiguate?
*/
TemplateBind = {

// construct binding meta-data

_preprocessBindAnnotations: function(prototype, list) {
// create a virtual annotation list, must be concretized at instance time
prototype._nodes = [];
// process annotations that have been parsed from template
list.forEach(function(annotation) {
// where to find the node in the concretized list
var index = prototype._nodes.push(annotation) - 1;
// TODO(sjmiles): we need to support multi-bind, right now you only get
// one (not including kind === `id`)
annotation.bindings.forEach(function(binding) {
prototype._bindAnnotationBinding(binding, index);
});
});
},

// _nodes[index][<binding.name=>]{{binding.value}}
_bindAnnotationBinding: function(binding, index) {
// capture the node index
binding.index = index;
// discover top-level property (model) from path
var path = binding.value;
var i = path.indexOf('.');
// [name=]{{model[.subpath]}}
var model = (i >= 0) ? path.slice(0, i) : path;
// add 'annotation' binding effect for property 'model'
this.addPropertyEffect(model, 'annotation', binding);
}

// concretize `_nodes` map (annotation based)

marshalAnnotatedNodes: function(nodes, root) {
return nodes.map(function(a) {
return Template.findAnnotatedNode(root, a);
};
}

});

</script>
Loading