polymer-rails 0.2.8 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -3
- data/app/assets/javascripts/polymer/polymer-micro.html +36 -0
- data/app/assets/javascripts/polymer/polymer-mini.html +45 -0
- data/app/assets/javascripts/polymer/polymer.html +59 -11
- data/app/assets/javascripts/polymer/src/lib/annotations/annotations.html +262 -0
- data/app/assets/javascripts/polymer/src/lib/annotations/demo/app-chrome.html +60 -0
- data/app/assets/javascripts/polymer/src/lib/array-observe.html +118 -0
- data/app/assets/javascripts/polymer/src/lib/array-splice.html +262 -0
- data/app/assets/javascripts/polymer/src/lib/async.html +68 -0
- data/app/assets/javascripts/polymer/src/lib/base.html +117 -0
- data/app/assets/javascripts/polymer/src/lib/bind/accessors.html +223 -0
- data/app/assets/javascripts/polymer/src/lib/bind/demo/app-chrome.html +28 -0
- data/app/assets/javascripts/polymer/src/lib/bind/demo/app.html +29 -0
- data/app/assets/javascripts/polymer/src/lib/bind/demo/src/annotations-bind-demo.html +76 -0
- data/app/assets/javascripts/polymer/src/lib/bind/demo/src/bind-demo.html +83 -0
- data/app/assets/javascripts/polymer/src/lib/bind/effects.html +80 -0
- data/app/assets/javascripts/polymer/src/lib/case-map.html +46 -0
- data/app/assets/javascripts/polymer/src/lib/collection.html +179 -0
- data/app/assets/javascripts/polymer/src/lib/css-parse.html +131 -0
- data/app/assets/javascripts/polymer/src/lib/debounce.html +69 -0
- data/app/assets/javascripts/polymer/src/lib/dom-api.html +467 -0
- data/app/assets/javascripts/polymer/src/lib/dom-module.html +68 -0
- data/app/assets/javascripts/polymer/src/lib/event-api.html +92 -0
- data/app/assets/javascripts/polymer/src/lib/expr/focus.html +22 -0
- data/app/assets/javascripts/polymer/src/lib/expr/gestures.html +1 -0
- data/app/assets/javascripts/polymer/src/lib/expr/log.html +21 -0
- data/app/assets/javascripts/polymer/src/lib/expr/sinspect.html +235 -0
- data/app/assets/javascripts/polymer/src/lib/expr/style-auditor.html +123 -0
- data/app/assets/javascripts/polymer/src/lib/expr/style-protector.html +52 -0
- data/app/assets/javascripts/polymer/src/lib/gestures.html +284 -0
- data/app/assets/javascripts/polymer/src/lib/lang.html +21 -0
- data/app/assets/javascripts/polymer/src/lib/module.html +56 -0
- data/app/assets/javascripts/polymer/src/lib/polymer-bootstrap.html +78 -0
- data/app/assets/javascripts/polymer/src/lib/resolve-url.html +82 -0
- data/app/assets/javascripts/polymer/src/lib/settings.html +52 -0
- data/app/assets/javascripts/polymer/src/lib/style-defaults.html +32 -0
- data/app/assets/javascripts/polymer/src/lib/style-transformer.html +185 -0
- data/app/assets/javascripts/polymer/src/lib/style-util.html +77 -0
- data/app/assets/javascripts/polymer/src/lib/template/templatizer.html +132 -0
- data/app/assets/javascripts/polymer/src/lib/template/x-array-selector.html +178 -0
- data/app/assets/javascripts/polymer/src/lib/template/x-autobind.html +80 -0
- data/app/assets/javascripts/polymer/src/lib/template/x-if.html +115 -0
- data/app/assets/javascripts/polymer/src/lib/template/x-repeat.html +510 -0
- data/app/assets/javascripts/polymer/src/lib/template/x-template.html +39 -0
- data/app/assets/javascripts/polymer/src/lib/x-style.html +115 -0
- data/app/assets/javascripts/polymer/src/micro/attributes.html +180 -0
- data/app/assets/javascripts/polymer/src/micro/constructor.html +74 -0
- data/app/assets/javascripts/polymer/src/micro/extends.html +79 -0
- data/app/assets/javascripts/polymer/src/micro/mixins.html +40 -0
- data/app/assets/javascripts/polymer/src/micro/properties.html +96 -0
- data/app/assets/javascripts/polymer/src/micro/tag.html +28 -0
- data/app/assets/javascripts/polymer/src/mini/ready.html +180 -0
- data/app/assets/javascripts/polymer/src/mini/shadow.html +41 -0
- data/app/assets/javascripts/polymer/src/mini/shady.html +365 -0
- data/app/assets/javascripts/polymer/src/mini/template.html +56 -0
- data/app/assets/javascripts/polymer/src/polymer-lib.html +15 -0
- data/app/assets/javascripts/polymer/src/standard/annotations.html +198 -0
- data/app/assets/javascripts/polymer/src/standard/configure.html +160 -0
- data/app/assets/javascripts/polymer/src/standard/effects.html +215 -0
- data/app/assets/javascripts/polymer/src/standard/events.html +127 -0
- data/app/assets/javascripts/polymer/src/standard/notify-path.html +260 -0
- data/app/assets/javascripts/polymer/src/standard/resolveUrl.html +27 -0
- data/app/assets/javascripts/polymer/src/standard/styling.html +157 -0
- data/app/assets/javascripts/polymer/src/standard/utils.html +158 -0
- data/app/assets/javascripts/polymer/src/standard/x-styling.html +300 -0
- data/app/assets/javascripts/webcomponentsjs/webcomponents-lite.js +2270 -0
- data/lib/generators/polymer/component/templates/component.html.erb +3 -3
- data/lib/generators/polymer/install/install_generator.rb +1 -1
- data/lib/polymer-rails/version.rb +1 -1
- metadata +80 -5
- data/app/assets/javascripts/polymer/layout.html +0 -286
- data/app/assets/javascripts/polymer/polymer.js +0 -14
- data/app/assets/javascripts/polymer/webcomponents.js +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: deef29327e7cacd3555ebf35a6a764b468fd9dd3
|
4
|
+
data.tar.gz: 2632584344b12ababcd62cf92357325f11b7cc13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 733ba2dbc846cafb3ad9790f121ec8a276e5235f94c3b70d168009818cbc98c9ccef37ac1fabd369e33b9022b4e987ad48bed672ce1b4a0e5bf0bb1844c4eac9
|
7
|
+
data.tar.gz: fc83137fc6b4bf93a4e4f48262c246e576197aa55f5514d9344ca205045c0daeceff7884c4df6fdd7eef92b477734148caef4a1e4d88dac9906e17880d2ed0f1
|
data/README.md
CHANGED
@@ -15,6 +15,16 @@ This assets will be automatically compiled and required into component html file
|
|
15
15
|
* Note that if you're using sass or coffe precompilation, assets are required to use '.css.sass' and '.js.coffee' extensions.*
|
16
16
|
|
17
17
|
|
18
|
+
## Versions
|
19
|
+
Consider the 0.8 release to be our proposed API for 1.0. It is an “alpha” release — we fully expect some breaking changes as a result of the feedback we get.
|
20
|
+
|
21
|
+
This release is intended for early adopters who want to test out the new APIs and provide feedback. This release is optimized for performance and size, and is not yet a feature-complete replacement for 0.5.
|
22
|
+
|
23
|
+
0.8.x release is not compatible with the 0.5 APIs. For guidance on migrating an existing 0.5 element to the 0.8 APIs, see the [Migration guide](https://www.polymer-project.org/0.8/docs/migration.html).
|
24
|
+
|
25
|
+
* `0.2.x` Releases include Polymer versions `0.5.x`
|
26
|
+
* `0.3.x` Releases include Polymer versions `0.8.x`
|
27
|
+
|
18
28
|
|
19
29
|
## Installation
|
20
30
|
|
@@ -36,7 +46,7 @@ Or install it yourself as:
|
|
36
46
|
|
37
47
|
$ rails g polymer:install
|
38
48
|
|
39
|
-
- This generator adds `//= require
|
49
|
+
- This generator adds `//= require webcomponentsjs/webcomponents-lite` into `application.js` manifest file
|
40
50
|
- Creates `app/assets/components` and `application.html` manifest file where you can include all your components.
|
41
51
|
- Creates `vendor/assets/components` directory for third-party web components.
|
42
52
|
|
@@ -49,10 +59,10 @@ to import web components manifest to your app.
|
|
49
59
|
|
50
60
|
This generates new `<component-name>` component directory and `.html`, `.css`, `.js` files of the same name under `app/assets/components` folder.
|
51
61
|
|
52
|
-
Add your component to manifest file after requiring
|
62
|
+
Add your component to `.html` manifest file after requiring polymer:
|
53
63
|
|
54
64
|
//
|
55
|
-
//= require polymer/
|
65
|
+
//= require polymer/polymer
|
56
66
|
//= require component-name/component-name
|
57
67
|
|
58
68
|
And you can use your component in Rails application!
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<!--
|
2
|
+
@license
|
3
|
+
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
4
|
+
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
5
|
+
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
6
|
+
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
7
|
+
Code distributed by Google as part of the polymer project is also
|
8
|
+
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
9
|
+
-->
|
10
|
+
<link rel="import" href="src/polymer-lib.html">
|
11
|
+
<link rel="import" href="src/micro/tag.html">
|
12
|
+
<link rel="import" href="src/micro/mixins.html">
|
13
|
+
<link rel="import" href="src/micro/extends.html">
|
14
|
+
<link rel="import" href="src/micro/constructor.html">
|
15
|
+
<link rel="import" href="src/micro/properties.html">
|
16
|
+
<link rel="import" href="src/micro/attributes.html">
|
17
|
+
|
18
|
+
<script>
|
19
|
+
|
20
|
+
Polymer.Base.addFeature({
|
21
|
+
|
22
|
+
registerFeatures: function() {
|
23
|
+
this._prepIs();
|
24
|
+
this._prepMixins();
|
25
|
+
this._prepExtends();
|
26
|
+
this._prepConstructor();
|
27
|
+
},
|
28
|
+
|
29
|
+
initFeatures: function() {
|
30
|
+
this._marshalAttributes();
|
31
|
+
}
|
32
|
+
|
33
|
+
});
|
34
|
+
|
35
|
+
</script>
|
36
|
+
|
@@ -0,0 +1,45 @@
|
|
1
|
+
<!--
|
2
|
+
@license
|
3
|
+
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
4
|
+
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
5
|
+
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
6
|
+
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
7
|
+
Code distributed by Google as part of the polymer project is also
|
8
|
+
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
9
|
+
-->
|
10
|
+
|
11
|
+
<link rel="import" href="polymer-micro.html">
|
12
|
+
|
13
|
+
<link rel="import" href="src/mini/template.html">
|
14
|
+
<link rel="import" href="src/mini/ready.html">
|
15
|
+
<link rel="import" href="src/mini/shady.html">
|
16
|
+
<link rel="import" href="src/mini/shadow.html">
|
17
|
+
|
18
|
+
<script>
|
19
|
+
|
20
|
+
Polymer.DomModule = document.createElement('dom-module');
|
21
|
+
|
22
|
+
Polymer.Base.addFeature({
|
23
|
+
|
24
|
+
registerFeatures: function() {
|
25
|
+
this._prepIs();
|
26
|
+
this._prepMixins();
|
27
|
+
this._prepExtends();
|
28
|
+
this._prepConstructor();
|
29
|
+
this._prepTemplate();
|
30
|
+
this._prepContent();
|
31
|
+
},
|
32
|
+
|
33
|
+
initFeatures: function() {
|
34
|
+
this._poolContent();
|
35
|
+
this._pushHost();
|
36
|
+
this._stampTemplate();
|
37
|
+
this._popHost();
|
38
|
+
this._marshalAttributes();
|
39
|
+
this._readyContent();
|
40
|
+
}
|
41
|
+
|
42
|
+
});
|
43
|
+
|
44
|
+
</script>
|
45
|
+
|
@@ -1,11 +1,59 @@
|
|
1
|
-
<!--
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
The complete set of
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
<
|
1
|
+
<!--
|
2
|
+
@license
|
3
|
+
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
4
|
+
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
5
|
+
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
6
|
+
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
7
|
+
Code distributed by Google as part of the polymer project is also
|
8
|
+
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
9
|
+
-->
|
10
|
+
|
11
|
+
<link rel="import" href="polymer-mini.html">
|
12
|
+
|
13
|
+
<link rel="import" href="src/standard/annotations.html">
|
14
|
+
<link rel="import" href="src/standard/events.html">
|
15
|
+
<link rel="import" href="src/standard/utils.html">
|
16
|
+
<link rel="import" href="src/standard/effects.html">
|
17
|
+
<link rel="import" href="src/standard/configure.html">
|
18
|
+
<link rel="import" href="src/standard/notify-path.html">
|
19
|
+
<link rel="import" href="src/standard/resolveUrl.html">
|
20
|
+
<link rel="import" href="src/standard/styling.html">
|
21
|
+
<link rel="import" href="src/standard/x-styling.html">
|
22
|
+
|
23
|
+
<script>
|
24
|
+
|
25
|
+
Polymer.Base.addFeature({
|
26
|
+
|
27
|
+
registerFeatures: function() {
|
28
|
+
this._prepIs();
|
29
|
+
this._prepMixins();
|
30
|
+
this._prepExtends();
|
31
|
+
this._prepConstructor();
|
32
|
+
this._prepTemplate();
|
33
|
+
this._prepAnnotations();
|
34
|
+
this._prepEffects();
|
35
|
+
this._prepContent();
|
36
|
+
},
|
37
|
+
|
38
|
+
initFeatures: function() {
|
39
|
+
this._poolContent();
|
40
|
+
this._setupConfigure();
|
41
|
+
this._pushHost();
|
42
|
+
this._stampTemplate();
|
43
|
+
this._popHost();
|
44
|
+
this._marshalAnnotationReferences();
|
45
|
+
this._marshalInstanceEffects();
|
46
|
+
this._marshalAttributes();
|
47
|
+
this._marshalListeners();
|
48
|
+
this._readyContent();
|
49
|
+
}
|
50
|
+
|
51
|
+
});
|
52
|
+
|
53
|
+
</script>
|
54
|
+
|
55
|
+
<link rel="import" href="src/lib/x-style.html">
|
56
|
+
<link rel="import" href="src/lib/template/x-autobind.html">
|
57
|
+
<link rel="import" href="src/lib/template/x-template.html">
|
58
|
+
<link rel="import" href="src/lib/template/x-repeat.html">
|
59
|
+
<link rel="import" href="src/lib/template/x-array-selector.html">
|
@@ -0,0 +1,262 @@
|
|
1
|
+
<!--
|
2
|
+
@license
|
3
|
+
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
4
|
+
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
5
|
+
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
6
|
+
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
7
|
+
Code distributed by Google as part of the polymer project is also
|
8
|
+
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
9
|
+
-->
|
10
|
+
<link rel="import" href="../module.html">
|
11
|
+
<link rel="import" href="../case-map.html">
|
12
|
+
|
13
|
+
<script>
|
14
|
+
/**
|
15
|
+
* Scans a template to produce an annotation list that that associates
|
16
|
+
* metadata culled from markup with tree locations
|
17
|
+
* metadata and information to associate the metadata with nodes in an instance.
|
18
|
+
*
|
19
|
+
* Supported expressions include:
|
20
|
+
*
|
21
|
+
* Double-mustache annotations in text content. The annotation must be the only
|
22
|
+
* content in the tag, compound expressions are not supported.
|
23
|
+
*
|
24
|
+
* <[tag]>{{annotation}}<[tag]>
|
25
|
+
*
|
26
|
+
* Double-escaped annotations in an attribute, either {{}} or [[]].
|
27
|
+
*
|
28
|
+
* <[tag] someAttribute="{{annotation}}" another="[[annotation]]"><[tag]>
|
29
|
+
*
|
30
|
+
* `on-` style event declarations.
|
31
|
+
*
|
32
|
+
* <[tag] on-<event-name>="annotation"><[tag]>
|
33
|
+
*
|
34
|
+
* Note that the `annotations` feature does not implement any behaviors
|
35
|
+
* associated with these expressions, it only captures the data.
|
36
|
+
*
|
37
|
+
* Generated data-structure:
|
38
|
+
*
|
39
|
+
* [
|
40
|
+
* {
|
41
|
+
* id: '<id>',
|
42
|
+
* events: [
|
43
|
+
* {
|
44
|
+
* name: '<name>'
|
45
|
+
* value: '<annotation>'
|
46
|
+
* }, ...
|
47
|
+
* ],
|
48
|
+
* bindings: [
|
49
|
+
* {
|
50
|
+
* kind: ['text'|'attribute'],
|
51
|
+
* mode: ['{'|'['],
|
52
|
+
* name: '<name>'
|
53
|
+
* value: '<annotation>'
|
54
|
+
* }, ...
|
55
|
+
* ],
|
56
|
+
* // TODO(sjmiles): this is annotation-parent, not node-parent
|
57
|
+
* parent: <reference to parent annotation object>,
|
58
|
+
* index: <integer index in parent's childNodes collection>
|
59
|
+
* },
|
60
|
+
* ...
|
61
|
+
* ]
|
62
|
+
*
|
63
|
+
* @class Template feature
|
64
|
+
*/
|
65
|
+
|
66
|
+
// null-array (shared empty array to avoid null-checks)
|
67
|
+
Polymer.nar = [];
|
68
|
+
|
69
|
+
Polymer.Annotations = {
|
70
|
+
|
71
|
+
// preprocess-time
|
72
|
+
|
73
|
+
// construct and return a list of annotation records
|
74
|
+
// by scanning `template`'s content
|
75
|
+
//
|
76
|
+
parseAnnotations: function(template) {
|
77
|
+
var list = [];
|
78
|
+
var content = template._content || template.content;
|
79
|
+
this._parseNodeAnnotations(content, list);
|
80
|
+
return list;
|
81
|
+
},
|
82
|
+
|
83
|
+
// add annotations gleaned from subtree at `node` to `list`
|
84
|
+
_parseNodeAnnotations: function(node, list) {
|
85
|
+
return node.nodeType === Node.TEXT_NODE ?
|
86
|
+
this._parseTextNodeAnnotation(node, list) :
|
87
|
+
// TODO(sjmiles): are there other nodes we may encounter
|
88
|
+
// that are not TEXT_NODE but also not ELEMENT?
|
89
|
+
this._parseElementAnnotations(node, list);
|
90
|
+
},
|
91
|
+
|
92
|
+
// add annotations gleaned from TextNode `node` to `list`
|
93
|
+
_parseTextNodeAnnotation: function(node, list) {
|
94
|
+
var v = node.textContent, escape = v.slice(0, 2);
|
95
|
+
if (escape === '{{' || escape === '[[') {
|
96
|
+
// NOTE: use a space here so the textNode remains; some browsers
|
97
|
+
// (IE) evacipate an empty textNode.
|
98
|
+
node.textContent = ' ';
|
99
|
+
var annote = {
|
100
|
+
bindings: [{
|
101
|
+
kind: 'text',
|
102
|
+
mode: escape[0],
|
103
|
+
value: v.slice(2, -2)
|
104
|
+
}]
|
105
|
+
};
|
106
|
+
list.push(annote);
|
107
|
+
return annote;
|
108
|
+
}
|
109
|
+
},
|
110
|
+
|
111
|
+
// add annotations gleaned from Element `node` to `list`
|
112
|
+
_parseElementAnnotations: function(element, list) {
|
113
|
+
var annote = {
|
114
|
+
bindings: [],
|
115
|
+
events: []
|
116
|
+
};
|
117
|
+
this._parseChildNodesAnnotations(element, annote, list);
|
118
|
+
// TODO(sjmiles): is this for non-ELEMENT nodes? If so, we should
|
119
|
+
// change the contract of this method, or filter these out above.
|
120
|
+
if (element.attributes) {
|
121
|
+
this._parseNodeAttributeAnnotations(element, annote, list);
|
122
|
+
// TODO(sorvell): ad hoc callback for doing work on elements while
|
123
|
+
// leveraging annotator's tree walk.
|
124
|
+
// Consider adding an node callback registry and moving specific
|
125
|
+
// processing out of this module.
|
126
|
+
if (this.prepElement) {
|
127
|
+
this.prepElement(element);
|
128
|
+
}
|
129
|
+
}
|
130
|
+
if (annote.bindings.length || annote.events.length || annote.id) {
|
131
|
+
list.push(annote);
|
132
|
+
}
|
133
|
+
return annote;
|
134
|
+
},
|
135
|
+
|
136
|
+
// add annotations gleaned from children of `root` to `list`, `root`'s
|
137
|
+
// `annote` is supplied as it is the annote.parent of added annotations
|
138
|
+
_parseChildNodesAnnotations: function(root, annote, list, callback) {
|
139
|
+
if (root.firstChild) {
|
140
|
+
for (var i=0, node=root.firstChild; node; node=node.nextSibling, i++){
|
141
|
+
if (node.localName === 'template') {
|
142
|
+
// TODO(sjmiles): simply altering the .content reference didn't
|
143
|
+
// work (there was some confusion, might need verification)
|
144
|
+
var content = document.createDocumentFragment();
|
145
|
+
content.appendChild(node.content);
|
146
|
+
// TODO(sjmiles): using `nar` to avoid unnecessary allocation;
|
147
|
+
// in general the handling of these arrays needs some cleanup
|
148
|
+
// in this module
|
149
|
+
list.push({
|
150
|
+
bindings: Polymer.nar,
|
151
|
+
events: Polymer.nar,
|
152
|
+
templateContent: content,
|
153
|
+
parent: annote,
|
154
|
+
index: i
|
155
|
+
});
|
156
|
+
}
|
157
|
+
//
|
158
|
+
var childAnnotation = this._parseNodeAnnotations(node, list, callback);
|
159
|
+
if (childAnnotation) {
|
160
|
+
childAnnotation.parent = annote;
|
161
|
+
childAnnotation.index = i;
|
162
|
+
}
|
163
|
+
}
|
164
|
+
}
|
165
|
+
},
|
166
|
+
|
167
|
+
// add annotation data from attributes to the `annotation` for node `node`
|
168
|
+
// TODO(sjmiles): the distinction between an `annotation` and
|
169
|
+
// `annotation data` is not as clear as it could be
|
170
|
+
// Walk attributes backwards, since removeAttribute can be vetoed by
|
171
|
+
// IE in certain cases (e.g. <input value="foo">), resulting in the
|
172
|
+
// attribute staying in the attributes list
|
173
|
+
_parseNodeAttributeAnnotations: function(node, annotation) {
|
174
|
+
for (var i=node.attributes.length-1, a; (a=node.attributes[i]); i--) {
|
175
|
+
var n = a.name, v = a.value;
|
176
|
+
// id
|
177
|
+
if (n === 'id') {
|
178
|
+
annotation.id = v;
|
179
|
+
}
|
180
|
+
// events (on-*)
|
181
|
+
else if (n.slice(0, 3) === 'on-') {
|
182
|
+
node.removeAttribute(n);
|
183
|
+
annotation.events.push({
|
184
|
+
name: n.slice(3),
|
185
|
+
value: v
|
186
|
+
});
|
187
|
+
}
|
188
|
+
// bindings (other attributes)
|
189
|
+
else {
|
190
|
+
var b = this._parseNodeAttributeAnnotation(node, n, v);
|
191
|
+
if (b) {
|
192
|
+
annotation.bindings.push(b);
|
193
|
+
}
|
194
|
+
}
|
195
|
+
}
|
196
|
+
},
|
197
|
+
|
198
|
+
// construct annotation data from a generic attribute, or undefined
|
199
|
+
_parseNodeAttributeAnnotation: function(node, n, v) {
|
200
|
+
var mode = '', escape = v.slice(0, 2), name = n;
|
201
|
+
if (escape === '{{' || escape === '[[') {
|
202
|
+
// Mode (one-way or two)
|
203
|
+
mode = escape[0];
|
204
|
+
v = v.slice(2, -2);
|
205
|
+
// Negate
|
206
|
+
var not = false;
|
207
|
+
if (v[0] == '!') {
|
208
|
+
v = v.substring(1);
|
209
|
+
not = true;
|
210
|
+
}
|
211
|
+
// Attribute or property
|
212
|
+
var kind = 'property';
|
213
|
+
if (n[n.length-1] == '$') {
|
214
|
+
name = n.slice(0, -1);
|
215
|
+
kind = 'attribute';
|
216
|
+
}
|
217
|
+
// Custom notification event
|
218
|
+
var notifyEvent, colon;
|
219
|
+
if (mode == '{' && (colon = v.indexOf('::')) > 0) {
|
220
|
+
notifyEvent = v.substring(colon + 2);
|
221
|
+
v = v.substring(0, colon);
|
222
|
+
}
|
223
|
+
// Remove annotation
|
224
|
+
node.removeAttribute(n);
|
225
|
+
// Case hackery: attributes are lower-case, but bind targets
|
226
|
+
// (properties) are case sensitive. Gambit is to map dash-case to
|
227
|
+
// camel-case: `foo-bar` becomes `fooBar`.
|
228
|
+
// Attribute bindings are excepted.
|
229
|
+
if (kind === 'property') {
|
230
|
+
name = Polymer.CaseMap.dashToCamelCase(name);
|
231
|
+
}
|
232
|
+
return {
|
233
|
+
kind: kind,
|
234
|
+
mode: mode,
|
235
|
+
name: name,
|
236
|
+
value: v,
|
237
|
+
negate: not,
|
238
|
+
event: notifyEvent
|
239
|
+
};
|
240
|
+
}
|
241
|
+
},
|
242
|
+
|
243
|
+
// instance-time
|
244
|
+
|
245
|
+
_localSubTree: function(node, host) {
|
246
|
+
return (node === host) ? node.childNodes :
|
247
|
+
(node.lightChildren || node.childNodes);
|
248
|
+
},
|
249
|
+
|
250
|
+
findAnnotatedNode: function(root, annote) {
|
251
|
+
// recursively ascend tree until we hit root
|
252
|
+
var parent = annote.parent &&
|
253
|
+
Polymer.Annotations.findAnnotatedNode(root, annote.parent);
|
254
|
+
// unwind the stack, returning the indexed node at each level
|
255
|
+
return !parent ? root :
|
256
|
+
Polymer.Annotations._localSubTree(parent, root)[annote.index];
|
257
|
+
}
|
258
|
+
|
259
|
+
};
|
260
|
+
|
261
|
+
|
262
|
+
</script>
|