Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1386)

Unified Diff: third_party/polymer/v0_8/components-chromium/polymer/src/lib/bind/demo/src/annotations-bind-demo-extracted.js

Issue 1082403004: Import Polymer 0.8 and several key elements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Also remove polymer/explainer Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/polymer/v0_8/components-chromium/polymer/src/lib/bind/demo/src/annotations-bind-demo-extracted.js
diff --git a/third_party/polymer/v0_8/components-chromium/polymer/src/lib/bind/demo/src/annotations-bind-demo-extracted.js b/third_party/polymer/v0_8/components-chromium/polymer/src/lib/bind/demo/src/annotations-bind-demo-extracted.js
new file mode 100644
index 0000000000000000000000000000000000000000..2afcdd8c9fe546c32cbc9c24496c63f6115399f4
--- /dev/null
+++ b/third_party/polymer/v0_8/components-chromium/polymer/src/lib/bind/demo/src/annotations-bind-demo-extracted.js
@@ -0,0 +1,59 @@
+
+
+ // TODO(sjmiles): should 'bind-annotations' blend the other two modules
+ // somehow so we don't need to include all three here?
+ using(['Annotations', 'bind', 'bind-annotations'],
+
+ function(Annotations, Bind, BindAnnotations) {
+
+ var out = document.querySelector('#abd');
+ out.innerHTML += '<hr><h3>annotations-bind demo</h3><hr>';
+
+ // phase one: prototyping
+
+ var prototype = {};
+ var template = currentImport.querySelector('template');
+ var list = Templabindinate(prototype, template);
+
+ // phase two: instancing
+
+ var model = Object.create(prototype);
+ var dom = Instancinance(model, template);
+ document.body.appendChild(dom);
+
+ // affect model
+
+ model.text = 'Hello from Model';
+ model.path = 'path';
+ model.otherpath = 'other.path';
+ model.specialStyle = {backgroundColor: "red"};
+
+ // effects visible in dom
+
+ var foo = dom.querySelector('#foo');
+ out.innerHTML +=
+ 'foo.<b>path</b> = "' + model.path + '"<br>'
+ + 'foo.<b>otherpath</b> = "' + model.otherpath + '"<br>'
+ + 'foo.<b>specialStyle</b> = "' + JSON.stringify(model.specialStyle)+ '"<br>'
+ ;
+
+ // ad hoc abstractions
+
+ function Templabindinate(model, template) {
+ Bind.prepareModel(model);
+ var list = Annotations.parseAnnotations(template);
+ BindAnnotations.addEffects(model, list);
+ return list;
+ }
+
+ function Instancinance(model, template) {
+ Bind.prepareInstance(model);
+ Bind.createBindings(model);
+ var dom = document.importNode(template.content, true);
+ model._nodes = BindAnnotations.marshalAnnotatedNodes(model._nodes, dom,
+ Annotations.findAnnotatedNode);
+ return dom;
+ }
+
+ });
+

Powered by Google App Engine
This is Rietveld 408576698