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

Unified Diff: third_party/polymer/v1_0/components-chromium/polymer/polymer-extracted.js

Issue 1187823002: Update Polymer components and re-run reproduce.sh (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 6 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/v1_0/components-chromium/polymer/polymer-extracted.js
diff --git a/third_party/polymer/v1_0/components-chromium/polymer/polymer-extracted.js b/third_party/polymer/v1_0/components-chromium/polymer/polymer-extracted.js
index 5f52247199a9ac9e021e8926c8081d7ad7d32f93..efa86c507b5db26e50bd18dae8cfde6a9577a1c8 100644
--- a/third_party/polymer/v1_0/components-chromium/polymer/polymer-extracted.js
+++ b/third_party/polymer/v1_0/components-chromium/polymer/polymer-extracted.js
@@ -1,38 +1,37 @@
Polymer.nar = [];
-
Polymer.Annotations = {
-parseAnnotations: function(template) {
+parseAnnotations: function (template) {
var list = [];
var content = template._content || template.content;
this._parseNodeAnnotations(content, list);
return list;
},
-_parseNodeAnnotations: function(node, list) {
+_parseNodeAnnotations: function (node, list) {
return node.nodeType === Node.TEXT_NODE ? this._parseTextNodeAnnotation(node, list) : this._parseElementAnnotations(node, list);
},
-_testEscape: function(value) {
+_testEscape: function (value) {
var escape = value.slice(0, 2);
-if (escape === "{{" || escape === "[[") {
+if (escape === '{{' || escape === '[[') {
return escape;
}
},
-_parseTextNodeAnnotation: function(node, list) {
+_parseTextNodeAnnotation: function (node, list) {
var v = node.textContent;
var escape = this._testEscape(v);
if (escape) {
-node.textContent = " ";
+node.textContent = ' ';
var annote = {
-bindings: [ {
-kind: "text",
+bindings: [{
+kind: 'text',
mode: escape[0],
value: v.slice(2, -2).trim()
-} ]
+}]
};
list.push(annote);
return annote;
}
},
-_parseElementAnnotations: function(element, list) {
+_parseElementAnnotations: function (element, list) {
var annote = {
bindings: [],
events: []
@@ -49,10 +48,10 @@ list.push(annote);
}
return annote;
},
-_parseChildNodesAnnotations: function(root, annote, list, callback) {
+_parseChildNodesAnnotations: function (root, annote, list, callback) {
if (root.firstChild) {
for (var i = 0, node = root.firstChild; node; node = node.nextSibling, i++) {
-if (node.localName === "template" && !node.hasAttribute("preserve-content")) {
+if (node.localName === 'template' && !node.hasAttribute('preserve-content')) {
this._parseTemplate(node, i, list, annote);
}
var childAnnotation = this._parseNodeAnnotations(node, list, callback);
@@ -63,7 +62,7 @@ childAnnotation.index = i;
}
}
},
-_parseTemplate: function(node, index, list, parent) {
+_parseTemplate: function (node, index, list, parent) {
var content = document.createDocumentFragment();
content._notes = this.parseAnnotations(node);
content.appendChild(node.content);
@@ -75,12 +74,12 @@ parent: parent,
index: index
});
},
-_parseNodeAttributeAnnotations: function(node, annotation) {
+_parseNodeAttributeAnnotations: function (node, annotation) {
for (var i = node.attributes.length - 1, a; a = node.attributes[i]; i--) {
var n = a.name, v = a.value;
-if (n === "id" && !this._testEscape(v)) {
+if (n === 'id' && !this._testEscape(v)) {
annotation.id = v;
-} else if (n.slice(0, 3) === "on-") {
+} else if (n.slice(0, 3) === 'on-') {
node.removeAttribute(n);
annotation.events.push({
name: n.slice(3),
@@ -94,7 +93,7 @@ annotation.bindings.push(b);
}
}
},
-_parseNodeAttributeAnnotation: function(node, n, v) {
+_parseNodeAttributeAnnotation: function (node, n, v) {
var escape = this._testEscape(v);
if (escape) {
var customEvent;
@@ -102,26 +101,26 @@ var name = n;
var mode = escape[0];
v = v.slice(2, -2).trim();
var not = false;
-if (v[0] == "!") {
+if (v[0] == '!') {
v = v.substring(1);
not = true;
}
-var kind = "property";
-if (n[n.length - 1] == "$") {
+var kind = 'property';
+if (n[n.length - 1] == '$') {
name = n.slice(0, -1);
-kind = "attribute";
+kind = 'attribute';
}
var notifyEvent, colon;
-if (mode == "{" && (colon = v.indexOf("::")) > 0) {
+if (mode == '{' && (colon = v.indexOf('::')) > 0) {
notifyEvent = v.substring(colon + 2);
v = v.substring(0, colon);
customEvent = true;
}
-if (node.localName == "input" && n == "value") {
-node.setAttribute(n, "");
+if (node.localName == 'input' && n == 'value') {
+node.setAttribute(n, '');
}
node.removeAttribute(n);
-if (kind === "property") {
+if (kind === 'property') {
name = Polymer.CaseMap.dashToCamelCase(name);
}
return {
@@ -135,30 +134,29 @@ customEvent: customEvent
};
}
},
-_localSubTree: function(node, host) {
+_localSubTree: function (node, host) {
return node === host ? node.childNodes : node._lightChildren || node.childNodes;
},
-findAnnotatedNode: function(root, annote) {
+findAnnotatedNode: function (root, annote) {
var parent = annote.parent && Polymer.Annotations.findAnnotatedNode(root, annote.parent);
return !parent ? root : Polymer.Annotations._localSubTree(parent, root)[annote.index];
}
};
-
-(function() {
+(function () {
function resolveCss(cssText, ownerDocument) {
-return cssText.replace(CSS_URL_RX, function(m, pre, url, post) {
-return pre + "'" + resolve(url.replace(/["']/g, ""), ownerDocument) + "'" + post;
+return cssText.replace(CSS_URL_RX, function (m, pre, url, post) {
+return pre + '\'' + resolve(url.replace(/["']/g, ''), ownerDocument) + '\'' + post;
});
}
function resolveAttrs(element, ownerDocument) {
for (var name in URL_ATTRS) {
var a$ = URL_ATTRS[name];
for (var i = 0, l = a$.length, a, at, v; i < l && (a = a$[i]); i++) {
-if (name === "*" || element.localName === name) {
+if (name === '*' || element.localName === name) {
at = element.attributes[a];
v = at && at.value;
if (v && v.search(BINDING_RX) < 0) {
-at.value = a === "style" ? resolveCss(v, ownerDocument) : resolve(v, ownerDocument);
+at.value = a === 'style' ? resolveCss(v, ownerDocument) : resolve(v, ownerDocument);
}
}
}
@@ -173,20 +171,25 @@ var tempDoc;
var tempDocBase;
function resolveUrl(url, baseUri) {
if (!tempDoc) {
-tempDoc = document.implementation.createHTMLDocument("temp");
-tempDocBase = tempDoc.createElement("base");
+tempDoc = document.implementation.createHTMLDocument('temp');
+tempDocBase = tempDoc.createElement('base');
tempDoc.head.appendChild(tempDocBase);
}
tempDocBase.href = baseUri;
return resolve(url, tempDoc);
}
function getUrlResolver(ownerDocument) {
-return ownerDocument.__urlResolver || (ownerDocument.__urlResolver = ownerDocument.createElement("a"));
+return ownerDocument.__urlResolver || (ownerDocument.__urlResolver = ownerDocument.createElement('a'));
}
var CSS_URL_RX = /(url\()([^)]*)(\))/g;
var URL_ATTRS = {
-"*": [ "href", "src", "style", "url" ],
-form: [ "action" ]
+'*': [
+'href',
+'src',
+'style',
+'url'
+],
+form: ['action']
};
var BINDING_RX = /\{\{|\[\[/;
Polymer.ResolveUrl = {
@@ -194,10 +197,9 @@ resolveCss: resolveCss,
resolveAttrs: resolveAttrs,
resolveUrl: resolveUrl
};
-})();
-
+}());
Polymer.Base._addFeature({
-_prepAnnotations: function() {
+_prepAnnotations: function () {
if (!this._template) {
this._notes = [];
} else {
@@ -207,7 +209,7 @@ this._processAnnotations(this._notes);
Polymer.Annotations.prepElement = null;
}
},
-_processAnnotations: function(notes) {
+_processAnnotations: function (notes) {
for (var i = 0; i < notes.length; i++) {
var note = notes[i];
for (var j = 0; j < note.bindings.length; j++) {
@@ -224,9 +226,9 @@ var bindings = [];
for (var prop in pp) {
bindings.push({
index: note.index,
-kind: "property",
-mode: "{",
-name: "_parent_" + prop,
+kind: 'property',
+mode: '{',
+name: '_parent_' + prop,
model: prop,
value: prop
});
@@ -235,10 +237,10 @@ note.bindings = note.bindings.concat(bindings);
}
}
},
-_discoverTemplateParentProps: function(notes) {
+_discoverTemplateParentProps: function (notes) {
var pp = {};
-notes.forEach(function(n) {
-n.bindings.forEach(function(b) {
+notes.forEach(function (n) {
+n.bindings.forEach(function (b) {
if (b.signature) {
var args = b.signature.args;
for (var k = 0; k < args.length; k++) {
@@ -255,104 +257,105 @@ Polymer.Base.mixin(pp, tpp);
});
return pp;
},
-_prepElement: function(element) {
+_prepElement: function (element) {
Polymer.ResolveUrl.resolveAttrs(element, this._template.ownerDocument);
},
_findAnnotatedNode: Polymer.Annotations.findAnnotatedNode,
-_marshalAnnotationReferences: function() {
+_marshalAnnotationReferences: function () {
if (this._template) {
this._marshalIdNodes();
this._marshalAnnotatedNodes();
this._marshalAnnotatedListeners();
}
},
-_configureAnnotationReferences: function() {
+_configureAnnotationReferences: function () {
this._configureTemplateContent();
},
-_configureTemplateContent: function() {
-this._notes.forEach(function(note, i) {
+_configureTemplateContent: function () {
+this._notes.forEach(function (note, i) {
if (note.templateContent) {
this._nodes[i]._content = note.templateContent;
}
}, this);
},
-_marshalIdNodes: function() {
+_marshalIdNodes: function () {
this.$ = {};
-this._notes.forEach(function(a) {
+this._notes.forEach(function (a) {
if (a.id) {
this.$[a.id] = this._findAnnotatedNode(this.root, a);
}
}, this);
},
-_marshalAnnotatedNodes: function() {
+_marshalAnnotatedNodes: function () {
if (this._nodes) {
-this._nodes = this._nodes.map(function(a) {
+this._nodes = this._nodes.map(function (a) {
return this._findAnnotatedNode(this.root, a);
}, this);
}
},
-_marshalAnnotatedListeners: function() {
-this._notes.forEach(function(a) {
+_marshalAnnotatedListeners: function () {
+this._notes.forEach(function (a) {
if (a.events && a.events.length) {
var node = this._findAnnotatedNode(this.root, a);
-a.events.forEach(function(e) {
+a.events.forEach(function (e) {
this.listen(node, e.name, e.value);
}, this);
}
}, this);
}
});
-
Polymer.Base._addFeature({
listeners: {},
-_listenListeners: function(listeners) {
+_listenListeners: function (listeners) {
var node, name, key;
for (key in listeners) {
-if (key.indexOf(".") < 0) {
+if (key.indexOf('.') < 0) {
node = this;
name = key;
} else {
-name = key.split(".");
+name = key.split('.');
node = this.$[name[0]];
name = name[1];
}
this.listen(node, name, listeners[key]);
}
},
-listen: function(node, eventName, methodName) {
+listen: function (node, eventName, methodName) {
this._listen(node, eventName, this._createEventHandler(node, eventName, methodName));
},
-_createEventHandler: function(node, eventName, methodName) {
+_createEventHandler: function (node, eventName, methodName) {
var host = this;
-return function(e) {
+return function (e) {
if (host[methodName]) {
host[methodName](e, e.detail);
} else {
-host._warn(host._logf("_createEventHandler", "listener method `" + methodName + "` not defined"));
+host._warn(host._logf('_createEventHandler', 'listener method `' + methodName + '` not defined'));
}
};
},
-_listen: function(node, eventName, handler) {
+_listen: function (node, eventName, handler) {
node.addEventListener(eventName, handler);
}
});
-
-(function() {
-"use strict";
-var HAS_NATIVE_TA = typeof document.head.style.touchAction === "string";
-var GESTURE_KEY = "__polymerGestures";
-var HANDLED_OBJ = "__polymerGesturesHandled";
-var TOUCH_ACTION = "__polymerGesturesTouchAction";
+(function () {
+'use strict';
+var HAS_NATIVE_TA = typeof document.head.style.touchAction === 'string';
+var GESTURE_KEY = '__polymerGestures';
+var HANDLED_OBJ = '__polymerGesturesHandled';
+var TOUCH_ACTION = '__polymerGesturesTouchAction';
var TAP_DISTANCE = 25;
var TRACK_DISTANCE = 5;
var TRACK_LENGTH = 2;
var MOUSE_TIMEOUT = 2500;
-var MOUSE_EVENTS = [ "mousedown", "mousemove", "mouseup", "click" ];
-var mouseCanceller = function(mouseEvent) {
-mouseEvent[HANDLED_OBJ] = {
-skip: true
-};
-if (mouseEvent.type === "click") {
+var MOUSE_EVENTS = [
+'mousedown',
+'mousemove',
+'mouseup',
+'click'
+];
+var mouseCanceller = function (mouseEvent) {
+mouseEvent[HANDLED_OBJ] = { skip: true };
+if (mouseEvent.type === 'click') {
var path = Polymer.dom(mouseEvent).path;
for (var i = 0; i < path.length; i++) {
if (path[i] === POINTERSTATE.mouse.target) {
@@ -377,7 +380,7 @@ function ignoreMouse() {
if (!POINTERSTATE.mouse.mouseIgnoreJob) {
setupTeardownMouseCanceller(true);
}
-var unset = function() {
+var unset = function () {
setupTeardownMouseCanceller();
POINTERSTATE.mouse.target = null;
POINTERSTATE.mouse.mouseIgnoreJob = null;
@@ -399,7 +402,7 @@ scrollDecided: false
};
function firstTouchAction(ev) {
var path = Polymer.dom(ev).path;
-var ta = "auto";
+var ta = 'auto';
for (var i = 0, n; i < path.length; i++) {
n = path[i];
if (n[TOUCH_ACTION]) {
@@ -412,7 +415,7 @@ return ta;
var Gestures = {
gestures: {},
recognizers: [],
-deepTargetFind: function(x, y) {
+deepTargetFind: function (x, y) {
var node = document.elementFromPoint(x, y);
var next = node;
while (next && next.shadowRoot) {
@@ -423,7 +426,7 @@ node = next;
}
return node;
},
-handleNative: function(ev) {
+handleNative: function (ev) {
var handled;
var type = ev.type;
var node = ev.currentTarget;
@@ -434,9 +437,9 @@ return;
}
if (!ev[HANDLED_OBJ]) {
ev[HANDLED_OBJ] = {};
-if (type.slice(0, 5) === "touch") {
+if (type.slice(0, 5) === 'touch') {
var t = ev.changedTouches[0];
-if (type === "touchstart") {
+if (type === 'touchstart') {
if (ev.touches.length === 1) {
POINTERSTATE.touch.id = t.identifier;
}
@@ -445,11 +448,11 @@ if (POINTERSTATE.touch.id !== t.identifier) {
return;
}
if (!HAS_NATIVE_TA) {
-if (type === "touchstart" || type === "touchmove") {
+if (type === 'touchstart' || type === 'touchmove') {
Gestures.handleTouchAction(ev);
}
}
-if (type === "touchend") {
+if (type === 'touchend') {
POINTERSTATE.mouse.target = Polymer.dom(ev).rootTarget;
ignoreMouse(true);
}
@@ -468,14 +471,14 @@ r[type](ev);
}
}
},
-handleTouchAction: function(ev) {
+handleTouchAction: function (ev) {
var t = ev.changedTouches[0];
var type = ev.type;
-if (type === "touchstart") {
+if (type === 'touchstart') {
POINTERSTATE.touch.x = t.clientX;
POINTERSTATE.touch.y = t.clientY;
POINTERSTATE.touch.scrollDecided = false;
-} else if (type === "touchmove") {
+} else if (type === 'touchmove') {
if (POINTERSTATE.touch.scrollDecided) {
return;
}
@@ -484,11 +487,12 @@ var ta = firstTouchAction(ev);
var prevent = false;
var dx = Math.abs(POINTERSTATE.touch.x - t.clientX);
var dy = Math.abs(POINTERSTATE.touch.y - t.clientY);
-if (!ev.cancelable) {} else if (ta === "none") {
+if (!ev.cancelable) {
+} else if (ta === 'none') {
prevent = true;
-} else if (ta === "pan-x") {
+} else if (ta === 'pan-x') {
prevent = dy > dx;
-} else if (ta === "pan-y") {
+} else if (ta === 'pan-y') {
prevent = dx > dy;
}
if (prevent) {
@@ -496,7 +500,7 @@ ev.preventDefault();
}
}
},
-add: function(node, evType, handler) {
+add: function (node, evType, handler) {
var recognizer = this.gestures[evType];
var deps = recognizer.deps;
var name = recognizer.name;
@@ -518,19 +522,19 @@ if (recognizer.touchAction) {
this.setTouchAction(node, recognizer.touchAction);
}
},
-register: function(recog) {
+register: function (recog) {
this.recognizers.push(recog);
for (var i = 0; i < recog.emits.length; i++) {
this.gestures[recog.emits[i]] = recog;
}
},
-setTouchAction: function(node, value) {
+setTouchAction: function (node, value) {
if (HAS_NATIVE_TA) {
node.style.touchAction = value;
}
node[TOUCH_ACTION] = value;
},
-fire: function(target, type, detail) {
+fire: function (target, type, detail) {
var ev = new CustomEvent(type, {
detail: detail,
bubbles: true,
@@ -540,26 +544,33 @@ target.dispatchEvent(ev);
}
};
Gestures.register({
-name: "downup",
-deps: [ "mousedown", "touchstart", "touchend" ],
-emits: [ "down", "up" ],
-mousedown: function(e) {
+name: 'downup',
+deps: [
+'mousedown',
+'touchstart',
+'touchend'
+],
+emits: [
+'down',
+'up'
+],
+mousedown: function (e) {
var t = e.currentTarget;
var self = this;
var upfn = function upfn(e) {
-self.fire("up", t, e);
-document.removeEventListener("mouseup", upfn);
+self.fire('up', t, e);
+document.removeEventListener('mouseup', upfn);
};
-document.addEventListener("mouseup", upfn);
-this.fire("down", t, e);
+document.addEventListener('mouseup', upfn);
+this.fire('down', t, e);
},
-touchstart: function(e) {
-this.fire("down", e.currentTarget, e.changedTouches[0]);
+touchstart: function (e) {
+this.fire('down', e.currentTarget, e.changedTouches[0]);
},
-touchend: function(e) {
-this.fire("up", e.currentTarget, e.changedTouches[0]);
+touchend: function (e) {
+this.fire('up', e.currentTarget, e.changedTouches[0]);
},
-fire: function(type, target, event) {
+fire: function (type, target, event) {
Gestures.fire(target, type, {
x: event.clientX,
y: event.clientY,
@@ -568,31 +579,36 @@ sourceEvent: event
}
});
Gestures.register({
-name: "track",
-touchAction: "none",
-deps: [ "mousedown", "touchstart", "touchmove", "touchend" ],
-emits: [ "track" ],
+name: 'track',
+touchAction: 'none',
+deps: [
+'mousedown',
+'touchstart',
+'touchmove',
+'touchend'
+],
+emits: ['track'],
info: {
x: 0,
y: 0,
-state: "start",
+state: 'start',
started: false,
moves: [],
-addMove: function(move) {
+addMove: function (move) {
if (this.moves.length > TRACK_LENGTH) {
this.moves.shift();
}
this.moves.push(move);
}
},
-clearInfo: function() {
-this.info.state = "start";
+clearInfo: function () {
+this.info.state = 'start';
this.info.started = false;
this.info.moves = [];
this.info.x = 0;
this.info.y = 0;
},
-hasMovedEnough: function(x, y) {
+hasMovedEnough: function (x, y) {
if (this.info.started) {
return true;
}
@@ -600,13 +616,13 @@ var dx = Math.abs(this.info.x - x);
var dy = Math.abs(this.info.y - y);
return dx >= TRACK_DISTANCE || dy >= TRACK_DISTANCE;
},
-mousedown: function(e) {
+mousedown: function (e) {
var t = e.currentTarget;
var self = this;
var movefn = function movefn(e) {
var x = e.clientX, y = e.clientY;
if (self.hasMovedEnough(x, y)) {
-self.info.state = self.info.started ? e.type === "mouseup" ? "end" : "track" : "start";
+self.info.state = self.info.started ? e.type === 'mouseup' ? 'end' : 'track' : 'start';
self.info.addMove({
x: x,
y: y
@@ -622,20 +638,20 @@ POINTERSTATE.tapPrevented = true;
movefn(e);
}
self.clearInfo();
-document.removeEventListener("mousemove", movefn);
-document.removeEventListener("mouseup", upfn);
+document.removeEventListener('mousemove', movefn);
+document.removeEventListener('mouseup', upfn);
};
-document.addEventListener("mousemove", movefn);
-document.addEventListener("mouseup", upfn);
+document.addEventListener('mousemove', movefn);
+document.addEventListener('mouseup', upfn);
this.info.x = e.clientX;
this.info.y = e.clientY;
},
-touchstart: function(e) {
+touchstart: function (e) {
var ct = e.changedTouches[0];
this.info.x = ct.clientX;
this.info.y = ct.clientY;
},
-touchmove: function(e) {
+touchmove: function (e) {
var t = e.currentTarget;
var ct = e.changedTouches[0];
var x = ct.clientX, y = ct.clientY;
@@ -645,16 +661,16 @@ x: x,
y: y
});
this.fire(t, ct);
-this.info.state = "track";
+this.info.state = 'track';
this.info.started = true;
}
},
-touchend: function(e) {
+touchend: function (e) {
var t = e.currentTarget;
var ct = e.changedTouches[0];
if (this.info.started) {
POINTERSTATE.tapPrevented = true;
-this.info.state = "end";
+this.info.state = 'end';
this.info.addMove({
x: ct.clientX,
y: ct.clientY
@@ -663,7 +679,7 @@ this.fire(t, ct);
}
this.clearInfo();
},
-fire: function(target, touch) {
+fire: function (target, touch) {
var secondlast = this.info.moves[this.info.moves.length - 2];
var lastmove = this.info.moves[this.info.moves.length - 1];
var dx = lastmove.x - this.info.x;
@@ -673,7 +689,7 @@ if (secondlast) {
ddx = lastmove.x - secondlast.x;
ddy = lastmove.y - secondlast.y;
}
-return Gestures.fire(target, "track", {
+return Gestures.fire(target, 'track', {
state: this.info.state,
x: touch.clientX,
y: touch.clientY,
@@ -682,48 +698,53 @@ dy: dy,
ddx: ddx,
ddy: ddy,
sourceEvent: touch,
-hover: function() {
+hover: function () {
return Gestures.deepTargetFind(touch.clientX, touch.clientY);
}
});
}
});
Gestures.register({
-name: "tap",
-deps: [ "mousedown", "click", "touchstart", "touchend" ],
-emits: [ "tap" ],
+name: 'tap',
+deps: [
+'mousedown',
+'click',
+'touchstart',
+'touchend'
+],
+emits: ['tap'],
start: {
x: NaN,
y: NaN
},
-reset: function() {
+reset: function () {
this.start.x = NaN;
this.start.y = NaN;
},
-save: function(e) {
+save: function (e) {
this.start.x = e.clientX;
this.start.y = e.clientY;
},
-mousedown: function(e) {
+mousedown: function (e) {
POINTERSTATE.tapPrevented = false;
this.save(e);
},
-click: function(e) {
+click: function (e) {
this.forward(e);
},
-touchstart: function(e) {
+touchstart: function (e) {
POINTERSTATE.tapPrevented = false;
this.save(e.changedTouches[0]);
},
-touchend: function(e) {
+touchend: function (e) {
this.forward(e.changedTouches[0]);
},
-forward: function(e) {
+forward: function (e) {
var dx = Math.abs(e.clientX - this.start.x);
var dy = Math.abs(e.clientY - this.start.y);
if (isNaN(dx) || isNaN(dy) || dx <= TAP_DISTANCE && dy <= TAP_DISTANCE) {
if (!POINTERSTATE.tapPrevented) {
-Gestures.fire(e.target, "tap", {
+Gestures.fire(e.target, 'tap', {
x: e.clientX,
y: e.clientY,
sourceEvent: e
@@ -734,32 +755,31 @@ this.reset();
}
});
var DIRECTION_MAP = {
-x: "pan-x",
-y: "pan-y",
-none: "none",
-all: "auto"
+x: 'pan-x',
+y: 'pan-y',
+none: 'none',
+all: 'auto'
};
Polymer.Base._addFeature({
-_listen: function(node, eventName, handler) {
+_listen: function (node, eventName, handler) {
if (Gestures.gestures[eventName]) {
Gestures.add(node, eventName, handler);
} else {
node.addEventListener(eventName, handler);
}
},
-setScrollDirection: function(direction, node) {
+setScrollDirection: function (direction, node) {
node = node || this;
-Gestures.setTouchAction(node, DIRECTION_MAP[direction] || "auto");
+Gestures.setTouchAction(node, DIRECTION_MAP[direction] || 'auto');
}
});
Polymer.Gestures = Gestures;
-})();
-
-Polymer.Async = function() {
+}());
+Polymer.Async = function () {
var currVal = 0;
var lastVal = 0;
var callbacks = [];
-var twiddle = document.createTextNode("");
+var twiddle = document.createTextNode('');
function runAsync(callback, waitTime) {
if (waitTime > 0) {
return ~setTimeout(callback, waitTime);
@@ -776,7 +796,7 @@ clearTimeout(~handle);
var idx = handle - lastVal;
if (idx >= 0) {
if (!callbacks[idx]) {
-throw "invalid async handle: " + handle;
+throw 'invalid async handle: ' + handle;
}
callbacks[idx] = null;
}
@@ -793,37 +813,34 @@ cb();
callbacks.splice(0, len);
lastVal += len;
}
-new (window.MutationObserver || JsMutationObserver)(atEndOfMicrotask).observe(twiddle, {
-characterData: true
-});
+new (window.MutationObserver || JsMutationObserver)(atEndOfMicrotask).observe(twiddle, { characterData: true });
return {
run: runAsync,
cancel: cancelAsync
};
}();
-
-Polymer.Debounce = function() {
+Polymer.Debounce = function () {
var Async = Polymer.Async;
-var Debouncer = function(context) {
+var Debouncer = function (context) {
this.context = context;
this.boundComplete = this.complete.bind(this);
};
Debouncer.prototype = {
-go: function(callback, wait) {
+go: function (callback, wait) {
var h;
-this.finish = function() {
+this.finish = function () {
Async.cancel(h);
};
h = Async.run(this.boundComplete, wait);
this.callback = callback;
},
-stop: function() {
+stop: function () {
if (this.finish) {
this.finish();
this.finish = null;
}
},
-complete: function() {
+complete: function () {
if (this.finish) {
this.stop();
this.callback.call(this.context);
@@ -841,12 +858,11 @@ return debouncer;
}
return debounce;
}();
-
Polymer.Base._addFeature({
-$$: function(slctr) {
+$$: function (slctr) {
return Polymer.dom(this.root).querySelector(slctr);
},
-toggleClass: function(name, bool, node) {
+toggleClass: function (name, bool, node) {
node = node || this;
if (arguments.length == 1) {
bool = !node.classList.contains(name);
@@ -857,18 +873,18 @@ Polymer.dom(node).classList.add(name);
Polymer.dom(node).classList.remove(name);
}
},
-toggleAttribute: function(name, bool, node) {
+toggleAttribute: function (name, bool, node) {
node = node || this;
if (arguments.length == 1) {
bool = !node.hasAttribute(name);
}
if (bool) {
-Polymer.dom(node).setAttribute(name, "");
+Polymer.dom(node).setAttribute(name, '');
} else {
Polymer.dom(node).removeAttribute(name);
}
},
-classFollows: function(name, toElement, fromElement) {
+classFollows: function (name, toElement, fromElement) {
if (fromElement) {
Polymer.dom(fromElement).classList.remove(name);
}
@@ -876,23 +892,23 @@ if (toElement) {
Polymer.dom(toElement).classList.add(name);
}
},
-attributeFollows: function(name, toElement, fromElement) {
+attributeFollows: function (name, toElement, fromElement) {
if (fromElement) {
Polymer.dom(fromElement).removeAttribute(name);
}
if (toElement) {
-Polymer.dom(toElement).setAttribute(name, "");
+Polymer.dom(toElement).setAttribute(name, '');
}
},
-getContentChildNodes: function(slctr) {
-return Polymer.dom(Polymer.dom(this.root).querySelector(slctr || "content")).getDistributedNodes();
+getContentChildNodes: function (slctr) {
+return Polymer.dom(Polymer.dom(this.root).querySelector(slctr || 'content')).getDistributedNodes();
},
-getContentChildren: function(slctr) {
-return this.getContentChildNodes(slctr).filter(function(n) {
+getContentChildren: function (slctr) {
+return this.getContentChildNodes(slctr).filter(function (n) {
return n.nodeType === Node.ELEMENT_NODE;
});
},
-fire: function(type, detail, options) {
+fire: function (type, detail, options) {
options = options || Polymer.nob;
var node = options.node || this;
var detail = detail === null || detail === undefined ? Polymer.nob : detail;
@@ -905,13 +921,13 @@ detail: detail
node.dispatchEvent(event);
return event;
},
-async: function(callback, waitTime) {
+async: function (callback, waitTime) {
return Polymer.Async.run(callback.bind(this), waitTime);
},
-cancelAsync: function(handle) {
+cancelAsync: function (handle) {
Polymer.Async.cancel(handle);
},
-arrayDelete: function(path, item) {
+arrayDelete: function (path, item) {
var index;
if (Array.isArray(path)) {
index = path.indexOf(item);
@@ -926,18 +942,18 @@ return this.splice(path, index, 1);
}
}
},
-transform: function(transform, node) {
+transform: function (transform, node) {
node = node || this;
node.style.webkitTransform = transform;
node.style.transform = transform;
},
-translate3d: function(x, y, z, node) {
+translate3d: function (x, y, z, node) {
node = node || this;
-this.transform("translate3d(" + x + "," + y + "," + z + ")", node);
+this.transform('translate3d(' + x + ',' + y + ',' + z + ')', node);
},
-importHref: function(href, onload, onerror) {
-var l = document.createElement("link");
-l.rel = "import";
+importHref: function (href, onload, onerror) {
+var l = document.createElement('link');
+l.rel = 'import';
l.href = href;
if (onload) {
l.onload = onload.bind(this);
@@ -948,7 +964,7 @@ l.onerror = onerror.bind(this);
document.head.appendChild(l);
return l;
},
-create: function(tag, props) {
+create: function (tag, props) {
var elt = document.createElement(tag);
if (props) {
for (var n in props) {
@@ -957,15 +973,14 @@ elt[n] = props[n];
}
return elt;
},
-mixin: function(target, source) {
+mixin: function (target, source) {
for (var i in source) {
target[i] = source[i];
}
}
});
-
Polymer.Bind = {
-prepareModel: function(model) {
+prepareModel: function (model) {
model._propertyEffects = {};
model._bindListeners = [];
var api = this._modelApi;
@@ -974,19 +989,15 @@ model[n] = api[n];
}
},
_modelApi: {
-_notifyChange: function(property) {
-var eventName = Polymer.CaseMap.camelToDashCase(property) + "-changed";
-this.fire(eventName, {
-value: this[property]
-}, {
-bubbles: false
-});
+_notifyChange: function (property) {
+var eventName = Polymer.CaseMap.camelToDashCase(property) + '-changed';
+this.fire(eventName, { value: this[property] }, { bubbles: false });
},
-_propertySet: function(property, value, effects) {
+_propertySet: function (property, value, effects) {
var old = this.__data__[property];
if (old !== value) {
this.__data__[property] = value;
-if (typeof value == "object") {
+if (typeof value == 'object') {
this._clearPath(property);
}
if (this._propertyChanged) {
@@ -998,37 +1009,37 @@ this._effectEffects(property, value, effects, old);
}
return old;
},
-_effectEffects: function(property, value, effects, old) {
-effects.forEach(function(fx) {
-var fn = Polymer.Bind["_" + fx.kind + "Effect"];
+_effectEffects: function (property, value, effects, old) {
+effects.forEach(function (fx) {
+var fn = Polymer.Bind['_' + fx.kind + 'Effect'];
if (fn) {
fn.call(this, property, value, fx.effect, old);
}
}, this);
},
-_clearPath: function(path) {
+_clearPath: function (path) {
for (var prop in this.__data__) {
-if (prop.indexOf(path + ".") === 0) {
+if (prop.indexOf(path + '.') === 0) {
this.__data__[prop] = undefined;
}
}
}
},
-ensurePropertyEffects: function(model, property) {
+ensurePropertyEffects: function (model, property) {
var fx = model._propertyEffects[property];
if (!fx) {
fx = model._propertyEffects[property] = [];
}
return fx;
},
-addPropertyEffect: function(model, property, kind, effect) {
+addPropertyEffect: function (model, property, kind, effect) {
var fx = this.ensurePropertyEffects(model, property);
fx.push({
kind: kind,
effect: effect
});
},
-createBindings: function(model) {
+createBindings: function (model) {
var fx$ = model._propertyEffects;
if (fx$) {
for (var n in fx$) {
@@ -1038,43 +1049,43 @@ this._createAccessors(model, n, fx);
}
}
},
-_sortPropertyEffects: function() {
+_sortPropertyEffects: function () {
var EFFECT_ORDER = {
-compute: 0,
-annotation: 1,
-computedAnnotation: 2,
-reflect: 3,
-notify: 4,
-observer: 5,
-complexObserver: 6,
-"function": 7
+'compute': 0,
+'annotation': 1,
+'computedAnnotation': 2,
+'reflect': 3,
+'notify': 4,
+'observer': 5,
+'complexObserver': 6,
+'function': 7
};
-return function(a, b) {
+return function (a, b) {
return EFFECT_ORDER[a.kind] - EFFECT_ORDER[b.kind];
};
}(),
-_createAccessors: function(model, property, effects) {
+_createAccessors: function (model, property, effects) {
var defun = {
-get: function() {
+get: function () {
return this.__data__[property];
}
};
-var setter = function(value) {
+var setter = function (value) {
this._propertySet(property, value, effects);
};
if (model.getPropertyInfo && model.getPropertyInfo(property).readOnly) {
-model["_set" + this.upper(property)] = setter;
+model['_set' + this.upper(property)] = setter;
} else {
defun.set = setter;
}
Object.defineProperty(model, property, defun);
},
-upper: function(name) {
+upper: function (name) {
return name[0].toUpperCase() + name.substring(1);
},
-_addAnnotatedListener: function(model, index, property, path, event) {
+_addAnnotatedListener: function (model, index, property, path, event) {
var fn = this._notedListenerFactory(property, path, this._isStructured(path), this._isEventBogus);
-var eventName = event || Polymer.CaseMap.camelToDashCase(property) + "-changed";
+var eventName = event || Polymer.CaseMap.camelToDashCase(property) + '-changed';
model._bindListeners.push({
index: index,
property: property,
@@ -1083,14 +1094,14 @@ changedFn: fn,
event: eventName
});
},
-_isStructured: function(path) {
-return path.indexOf(".") > 0;
+_isStructured: function (path) {
+return path.indexOf('.') > 0;
},
-_isEventBogus: function(e, target) {
+_isEventBogus: function (e, target) {
return e.path && e.path[0] !== target;
},
-_notedListenerFactory: function(property, path, isStructured, bogusTest) {
-return function(e, target) {
+_notedListenerFactory: function (property, path, isStructured, bogusTest) {
+return function (e, target) {
if (!bogusTest(e, target)) {
if (e.detail && e.detail.path) {
this.notifyPath(this._fixPath(path, property, e.detail.path), e.detail.value);
@@ -1107,22 +1118,21 @@ this.set(path, value);
}
};
},
-prepareInstance: function(inst) {
+prepareInstance: function (inst) {
inst.__data__ = Object.create(null);
},
-setupBindListeners: function(inst) {
-inst._bindListeners.forEach(function(info) {
+setupBindListeners: function (inst) {
+inst._bindListeners.forEach(function (info) {
var node = inst._nodes[info.index];
node.addEventListener(info.event, inst._notifyListener.bind(inst, info.changedFn));
});
}
};
-
Polymer.Base.extend(Polymer.Bind, {
-_shouldAddListener: function(effect) {
-return effect.name && effect.mode === "{" && !effect.negate && effect.kind != "attribute";
+_shouldAddListener: function (effect) {
+return effect.name && effect.mode === '{' && !effect.negate && effect.kind != 'attribute';
},
-_annotationEffect: function(source, value, effect) {
+_annotationEffect: function (source, value, effect) {
if (source != effect.value) {
value = this.get(effect.value);
this.__data__[effect.value] = value;
@@ -1132,24 +1142,24 @@ if (!effect.customEvent || this._nodes[effect.index][effect.name] !== calc) {
return this._applyEffectValue(calc, effect);
}
},
-_reflectEffect: function(source) {
+_reflectEffect: function (source) {
this.reflectPropertyToAttribute(source);
},
-_notifyEffect: function(source) {
+_notifyEffect: function (source) {
this._notifyChange(source);
},
-_functionEffect: function(source, value, fn, old) {
+_functionEffect: function (source, value, fn, old) {
fn.call(this, source, value, old);
},
-_observerEffect: function(source, value, effect, old) {
+_observerEffect: function (source, value, effect, old) {
var fn = this[effect.method];
if (fn) {
fn.call(this, value, old);
} else {
-this._warn(this._logf("_observerEffect", "observer method `" + effect.method + "` not defined"));
+this._warn(this._logf('_observerEffect', 'observer method `' + effect.method + '` not defined'));
}
},
-_complexObserverEffect: function(source, value, effect) {
+_complexObserverEffect: function (source, value, effect) {
var fn = this[effect.method];
if (fn) {
var args = Polymer.Bind._marshalArgs(this.__data__, effect, source, value);
@@ -1157,21 +1167,21 @@ if (args) {
fn.apply(this, args);
}
} else {
-this._warn(this._logf("_complexObserverEffect", "observer method `" + effect.method + "` not defined"));
+this._warn(this._logf('_complexObserverEffect', 'observer method `' + effect.method + '` not defined'));
}
},
-_computeEffect: function(source, value, effect) {
+_computeEffect: function (source, value, effect) {
var args = Polymer.Bind._marshalArgs(this.__data__, effect, source, value);
if (args) {
var fn = this[effect.method];
if (fn) {
this[effect.property] = fn.apply(this, args);
} else {
-this._warn(this._logf("_computeEffect", "compute method `" + effect.method + "` not defined"));
+this._warn(this._logf('_computeEffect', 'compute method `' + effect.method + '` not defined'));
}
}
},
-_annotatedComputationEffect: function(source, value, effect) {
+_annotatedComputationEffect: function (source, value, effect) {
var computedHost = this._rootDataHost || this;
var fn = computedHost[effect.method];
if (fn) {
@@ -1184,15 +1194,16 @@ computedvalue = !computedvalue;
this._applyEffectValue(computedvalue, effect);
}
} else {
-computedHost._warn(computedHost._logf("_annotatedComputationEffect", "compute method `" + effect.method + "` not defined"));
+computedHost._warn(computedHost._logf('_annotatedComputationEffect', 'compute method `' + effect.method + '` not defined'));
}
},
-_marshalArgs: function(model, effect, path, value) {
+_marshalArgs: function (model, effect, path, value) {
var values = [];
var args = effect.args;
for (var i = 0, l = args.length; i < l; i++) {
var arg = args[i];
var name = arg.name;
+var v;
if (arg.literal) {
v = arg.value;
} else if (arg.structured) {
@@ -1204,7 +1215,7 @@ if (args.length > 1 && v === undefined) {
return;
}
if (arg.wildcard) {
-var baseChanged = name.indexOf(path + ".") === 0;
+var baseChanged = name.indexOf(path + '.') === 0;
var matches = effect.trigger.name.indexOf(name) === 0 && !baseChanged;
values[i] = {
path: matches ? path : name,
@@ -1218,19 +1229,18 @@ values[i] = v;
return values;
}
});
-
Polymer.Base._addFeature({
-_addPropertyEffect: function(property, kind, effect) {
+_addPropertyEffect: function (property, kind, effect) {
Polymer.Bind.addPropertyEffect(this, property, kind, effect);
},
-_prepEffects: function() {
+_prepEffects: function () {
Polymer.Bind.prepareModel(this);
this._addAnnotationEffects(this._notes);
},
-_prepBindings: function() {
+_prepBindings: function () {
Polymer.Bind.createBindings(this);
},
-_addPropertyEffects: function(properties) {
+_addPropertyEffects: function (properties) {
if (properties) {
for (var p in properties) {
var prop = properties[p];
@@ -1241,10 +1251,10 @@ if (prop.computed) {
this._addComputedEffect(p, prop.computed);
}
if (prop.notify) {
-this._addPropertyEffect(p, "notify");
+this._addPropertyEffect(p, 'notify');
}
if (prop.reflectToAttribute) {
-this._addPropertyEffect(p, "reflect");
+this._addPropertyEffect(p, 'reflect');
}
if (prop.readOnly) {
Polymer.Bind.ensurePropertyEffects(this, p);
@@ -1252,10 +1262,10 @@ Polymer.Bind.ensurePropertyEffects(this, p);
}
}
},
-_addComputedEffect: function(name, expression) {
+_addComputedEffect: function (name, expression) {
var sig = this._parseMethod(expression);
-sig.args.forEach(function(arg) {
-this._addPropertyEffect(arg.model, "compute", {
+sig.args.forEach(function (arg) {
+this._addPropertyEffect(arg.model, 'compute', {
method: sig.method,
args: sig.args,
trigger: arg,
@@ -1263,39 +1273,39 @@ property: name
});
}, this);
},
-_addObserverEffect: function(property, observer) {
-this._addPropertyEffect(property, "observer", {
+_addObserverEffect: function (property, observer) {
+this._addPropertyEffect(property, 'observer', {
method: observer,
property: property
});
},
-_addComplexObserverEffects: function(observers) {
+_addComplexObserverEffects: function (observers) {
if (observers) {
-observers.forEach(function(observer) {
+observers.forEach(function (observer) {
this._addComplexObserverEffect(observer);
}, this);
}
},
-_addComplexObserverEffect: function(observer) {
+_addComplexObserverEffect: function (observer) {
var sig = this._parseMethod(observer);
-sig.args.forEach(function(arg) {
-this._addPropertyEffect(arg.model, "complexObserver", {
+sig.args.forEach(function (arg) {
+this._addPropertyEffect(arg.model, 'complexObserver', {
method: sig.method,
args: sig.args,
trigger: arg
});
}, this);
},
-_addAnnotationEffects: function(notes) {
+_addAnnotationEffects: function (notes) {
this._nodes = [];
-notes.forEach(function(note) {
+notes.forEach(function (note) {
var index = this._nodes.push(note) - 1;
-note.bindings.forEach(function(binding) {
+note.bindings.forEach(function (binding) {
this._addAnnotationEffect(binding, index);
}, this);
}, this);
},
-_addAnnotationEffect: function(note, index) {
+_addAnnotationEffect: function (note, index) {
if (Polymer.Bind._shouldAddListener(note)) {
Polymer.Bind._addAnnotatedListener(this, index, note.name, note.value, note.event);
}
@@ -1303,23 +1313,23 @@ if (note.signature) {
this._addAnnotatedComputationEffect(note, index);
} else {
note.index = index;
-this._addPropertyEffect(note.model, "annotation", note);
+this._addPropertyEffect(note.model, 'annotation', note);
}
},
-_addAnnotatedComputationEffect: function(note, index) {
+_addAnnotatedComputationEffect: function (note, index) {
var sig = note.signature;
if (sig.static) {
-this.__addAnnotatedComputationEffect("__static__", index, note, sig, null);
+this.__addAnnotatedComputationEffect('__static__', index, note, sig, null);
} else {
-sig.args.forEach(function(arg) {
+sig.args.forEach(function (arg) {
if (!arg.literal) {
this.__addAnnotatedComputationEffect(arg.model, index, note, sig, arg);
}
}, this);
}
},
-__addAnnotatedComputationEffect: function(property, index, note, sig, trigger) {
-this._addPropertyEffect(property, "annotatedComputation", {
+__addAnnotatedComputationEffect: function (property, index, note, sig, trigger) {
+this._addPropertyEffect(property, 'annotatedComputation', {
index: index,
kind: note.kind,
property: note.name,
@@ -1329,15 +1339,15 @@ args: sig.args,
trigger: trigger
});
},
-_parseMethod: function(expression) {
+_parseMethod: function (expression) {
var m = expression.match(/(\w*)\((.*)\)/);
if (m) {
var sig = {
method: m[1],
-"static": true
+static: true
};
if (m[2].trim()) {
-var args = m[2].replace(/\\,/g, "&comma;").split(",");
+var args = m[2].replace(/\\,/g, '&comma;').split(',');
return this._parseArgs(args, sig);
} else {
sig.args = Polymer.nar;
@@ -1345,8 +1355,8 @@ return sig;
}
}
},
-_parseArgs: function(argList, sig) {
-sig.args = argList.map(function(rawArg) {
+_parseArgs: function (argList, sig) {
+sig.args = argList.map(function (rawArg) {
var arg = this._parseArg(rawArg);
if (!arg.literal) {
sig.static = false;
@@ -1355,32 +1365,31 @@ return arg;
}, this);
return sig;
},
-_parseArg: function(rawArg) {
-var arg = rawArg.trim().replace(/&comma;/g, ",").replace(/\\(.)/g, "$1");
+_parseArg: function (rawArg) {
+var arg = rawArg.trim().replace(/&comma;/g, ',').replace(/\\(.)/g, '$1');
var a = {
name: arg,
model: this._modelForPath(arg)
};
var fc = arg[0];
-if (fc >= "0" && fc <= "9") {
-fc = "#";
+if (fc >= '0' && fc <= '9') {
+fc = '#';
}
switch (fc) {
-case "'":
+case '\'':
case '"':
a.value = arg.slice(1, -1);
a.literal = true;
break;
-
-case "#":
+case '#':
a.value = Number(arg);
a.literal = true;
break;
}
if (!a.literal) {
-a.structured = arg.indexOf(".") > 0;
+a.structured = arg.indexOf('.') > 0;
if (a.structured) {
-a.wildcard = arg.slice(-2) == ".*";
+a.wildcard = arg.slice(-2) == '.*';
if (a.wildcard) {
a.name = arg.slice(0, -2);
}
@@ -1388,50 +1397,49 @@ a.name = arg.slice(0, -2);
}
return a;
},
-_marshalInstanceEffects: function() {
+_marshalInstanceEffects: function () {
Polymer.Bind.prepareInstance(this);
Polymer.Bind.setupBindListeners(this);
},
-_applyEffectValue: function(value, info) {
+_applyEffectValue: function (value, info) {
var node = this._nodes[info.index];
-var property = info.property || info.name || "textContent";
-if (info.kind == "attribute") {
+var property = info.property || info.name || 'textContent';
+if (info.kind == 'attribute') {
this.serializeValueToAttribute(value, property, node);
} else {
-if (property === "className") {
+if (property === 'className') {
value = this._scopeElementClass(node, value);
}
-if (property === "textContent" || node.localName == "input" && property == "value") {
-value = value == undefined ? "" : value;
+if (property === 'textContent' || node.localName == 'input' && property == 'value') {
+value = value == undefined ? '' : value;
}
return node[property] = value;
}
},
-_executeStaticEffects: function() {
+_executeStaticEffects: function () {
if (this._propertyEffects.__static__) {
-this._effectEffects("__static__", null, this._propertyEffects.__static__);
+this._effectEffects('__static__', null, this._propertyEffects.__static__);
}
}
});
-
Polymer.Base._addFeature({
-_setupConfigure: function(initialConfig) {
+_setupConfigure: function (initialConfig) {
this._config = initialConfig || {};
this._handlers = [];
},
-_marshalAttributes: function() {
+_marshalAttributes: function () {
this._takeAttributesToModel(this._config);
},
-_configValue: function(name, value) {
+_configValue: function (name, value) {
this._config[name] = value;
},
-_beforeClientsReady: function() {
+_beforeClientsReady: function () {
this._configure();
},
-_configure: function() {
+_configure: function () {
this._configureAnnotationReferences();
var config = {};
-this.behaviors.forEach(function(b) {
+this.behaviors.forEach(function (b) {
this._configureProperties(b.properties, config);
}, this);
this._configureProperties(this.properties, config);
@@ -1439,33 +1447,33 @@ this._mixinConfigure(config, this._config);
this._config = config;
this._distributeConfig(this._config);
},
-_configureProperties: function(properties, config) {
+_configureProperties: function (properties, config) {
for (var i in properties) {
var c = properties[i];
if (c.value !== undefined) {
var value = c.value;
-if (typeof value == "function") {
+if (typeof value == 'function') {
value = value.call(this, this._config);
}
config[i] = value;
}
}
},
-_mixinConfigure: function(a, b) {
+_mixinConfigure: function (a, b) {
for (var prop in b) {
if (!this.getPropertyInfo(prop).readOnly) {
a[prop] = b[prop];
}
}
},
-_distributeConfig: function(config) {
+_distributeConfig: function (config) {
var fx$ = this._propertyEffects;
if (fx$) {
for (var p in config) {
var fx = fx$[p];
if (fx) {
for (var i = 0, l = fx.length, x; i < l && (x = fx[i]); i++) {
-if (x.kind === "annotation") {
+if (x.kind === 'annotation') {
var node = this._nodes[x.effect.index];
if (node._configValue) {
var value = p === x.effect.value ? config[p] : this.get(x.effect.value, config);
@@ -1477,12 +1485,12 @@ node._configValue(x.effect.name, value);
}
}
},
-_afterClientsReady: function() {
+_afterClientsReady: function () {
this._executeStaticEffects();
this._applyConfig(this._config);
this._flushHandlers();
},
-_applyConfig: function(config) {
+_applyConfig: function (config) {
for (var n in config) {
if (this[n] === undefined) {
var effects = this._propertyEffects[n];
@@ -1494,28 +1502,31 @@ this[n] = config[n];
}
}
},
-_notifyListener: function(fn, e) {
+_notifyListener: function (fn, e) {
if (!this._clientsReadied) {
-this._queueHandler([ fn, e, e.target ]);
+this._queueHandler([
+fn,
+e,
+e.target
+]);
} else {
return fn.call(this, e, e.target);
}
},
-_queueHandler: function(args) {
+_queueHandler: function (args) {
this._handlers.push(args);
},
-_flushHandlers: function() {
+_flushHandlers: function () {
var h$ = this._handlers;
for (var i = 0, l = h$.length, h; i < l && (h = h$[i]); i++) {
h[0].call(this, h[1], h[2]);
}
}
});
-
-(function() {
-"use strict";
+(function () {
+'use strict';
Polymer.Base._addFeature({
-notifyPath: function(path, value, fromAbove) {
+notifyPath: function (path, value, fromAbove) {
var old = this._propertySet(path, value);
if (old !== value) {
this._pathEffector(path, value);
@@ -1524,21 +1535,21 @@ this._notifyPath(path, value);
}
}
},
-_getPathParts: function(path) {
+_getPathParts: function (path) {
if (Array.isArray(path)) {
var parts = [];
for (var i = 0; i < path.length; i++) {
-var args = path[i].toString().split(".");
+var args = path[i].toString().split('.');
for (var j = 0; j < args.length; j++) {
parts.push(args[j]);
}
}
return parts;
} else {
-return path.toString().split(".");
+return path.toString().split('.');
}
},
-set: function(path, value, root) {
+set: function (path, value, root) {
var prop = root || this;
var parts = this._getPathParts(path);
var array;
@@ -1556,13 +1567,13 @@ array = Array.isArray(prop) ? prop : null;
}
prop[last] = value;
if (!root) {
-this.notifyPath(parts.join("."), value);
+this.notifyPath(parts.join('.'), value);
}
} else {
prop[path] = value;
}
},
-get: function(path, root) {
+get: function (path, root) {
var prop = root || this;
var parts = this._getPathParts(path);
var last = parts.pop();
@@ -1574,12 +1585,12 @@ return;
}
return prop[last];
},
-_pathEffector: function(path, value) {
+_pathEffector: function (path, value) {
var model = this._modelForPath(path);
var fx$ = this._propertyEffects[model];
if (fx$) {
-fx$.forEach(function(fx) {
-var fxFn = this["_" + fx.kind + "PathEffect"];
+fx$.forEach(function (fx) {
+var fxFn = this['_' + fx.kind + 'PathEffect'];
if (fxFn) {
fxFn.call(this, path, value, fx.effect);
}
@@ -1589,10 +1600,10 @@ if (this._boundPaths) {
this._notifyBoundPaths(path, value);
}
},
-_annotationPathEffect: function(path, value, effect) {
-if (effect.value === path || effect.value.indexOf(path + ".") === 0) {
+_annotationPathEffect: function (path, value, effect) {
+if (effect.value === path || effect.value.indexOf(path + '.') === 0) {
Polymer.Bind._annotationEffect.call(this, path, value, effect);
-} else if (path.indexOf(effect.value + ".") === 0 && !effect.negate) {
+} else if (path.indexOf(effect.value + '.') === 0 && !effect.negate) {
var node = this._nodes[effect.index];
if (node && node.notifyPath) {
var p = this._fixPath(effect.name, effect.value, path);
@@ -1600,26 +1611,26 @@ node.notifyPath(p, value, true);
}
}
},
-_complexObserverPathEffect: function(path, value, effect) {
+_complexObserverPathEffect: function (path, value, effect) {
if (this._pathMatchesEffect(path, effect)) {
Polymer.Bind._complexObserverEffect.call(this, path, value, effect);
}
},
-_computePathEffect: function(path, value, effect) {
+_computePathEffect: function (path, value, effect) {
if (this._pathMatchesEffect(path, effect)) {
Polymer.Bind._computeEffect.call(this, path, value, effect);
}
},
-_annotatedComputationPathEffect: function(path, value, effect) {
+_annotatedComputationPathEffect: function (path, value, effect) {
if (this._pathMatchesEffect(path, effect)) {
Polymer.Bind._annotatedComputationEffect.call(this, path, value, effect);
}
},
-_pathMatchesEffect: function(path, effect) {
+_pathMatchesEffect: function (path, effect) {
var effectArg = effect.trigger.name;
-return effectArg == path || effectArg.indexOf(path + ".") === 0 || effect.trigger.wildcard && path.indexOf(effectArg) === 0;
+return effectArg == path || effectArg.indexOf(path + '.') === 0 || effect.trigger.wildcard && path.indexOf(effectArg) === 0;
},
-linkPaths: function(to, from) {
+linkPaths: function (to, from) {
this._boundPaths = this._boundPaths || {};
if (from) {
this._boundPaths[to] = from;
@@ -1627,21 +1638,21 @@ this._boundPaths[to] = from;
this.unbindPath(to);
}
},
-unlinkPaths: function(path) {
+unlinkPaths: function (path) {
if (this._boundPaths) {
delete this._boundPaths[path];
}
},
-_notifyBoundPaths: function(path, value) {
+_notifyBoundPaths: function (path, value) {
var from, to;
for (var a in this._boundPaths) {
var b = this._boundPaths[a];
-if (path.indexOf(a + ".") == 0) {
+if (path.indexOf(a + '.') == 0) {
from = a;
to = b;
break;
}
-if (path.indexOf(b + ".") == 0) {
+if (path.indexOf(b + '.') == 0) {
from = b;
to = a;
break;
@@ -1652,45 +1663,43 @@ var p = this._fixPath(to, from, path);
this.notifyPath(p, value);
}
},
-_fixPath: function(property, root, path) {
+_fixPath: function (property, root, path) {
return property + path.slice(root.length);
},
-_notifyPath: function(path, value) {
+_notifyPath: function (path, value) {
var rootName = this._modelForPath(path);
var dashCaseName = Polymer.CaseMap.camelToDashCase(rootName);
var eventName = dashCaseName + this._EVENT_CHANGED;
this.fire(eventName, {
path: path,
value: value
-}, {
-bubbles: false
-});
+}, { bubbles: false });
},
-_modelForPath: function(path) {
-var dot = path.indexOf(".");
+_modelForPath: function (path) {
+var dot = path.indexOf('.');
return dot < 0 ? path : path.slice(0, dot);
},
-_EVENT_CHANGED: "-changed",
-_notifySplice: function(array, path, index, added, removed) {
-var splices = [ {
+_EVENT_CHANGED: '-changed',
+_notifySplice: function (array, path, index, added, removed) {
+var splices = [{
index: index,
addedCount: added,
removed: removed,
object: array,
-type: "splice"
-} ];
+type: 'splice'
+}];
var change = {
keySplices: Polymer.Collection.get(array).applySplices(splices),
indexSplices: splices
};
-this.set(path + ".splices", change);
+this.set(path + '.splices', change);
if (added != removed.length) {
-this.notifyPath(path + ".length", array.length);
+this.notifyPath(path + '.length', array.length);
}
change.keySplices = null;
change.indexSplices = null;
},
-push: function(path) {
+push: function (path) {
var array = this.get(path);
var args = Array.prototype.slice.call(arguments, 1);
var len = array.length;
@@ -1698,7 +1707,7 @@ var ret = array.push.apply(array, args);
this._notifySplice(array, path, len, args.length, []);
return ret;
},
-pop: function(path) {
+pop: function (path) {
var array = this.get(path);
var args = Array.prototype.slice.call(arguments, 1);
var rem = array.slice(-1);
@@ -1706,7 +1715,7 @@ var ret = array.pop.apply(array, args);
this._notifySplice(array, path, array.length, 0, rem);
return ret;
},
-splice: function(path, start, deleteCount) {
+splice: function (path, start, deleteCount) {
var array = this.get(path);
var args = Array.prototype.slice.call(arguments, 1);
var rem = array.slice(start, start + deleteCount);
@@ -1714,14 +1723,14 @@ var ret = array.splice.apply(array, args);
this._notifySplice(array, path, start, args.length - 2, rem);
return ret;
},
-shift: function(path) {
+shift: function (path) {
var array = this.get(path);
var args = Array.prototype.slice.call(arguments, 1);
var ret = array.shift.apply(array, args);
-this._notifySplice(array, path, 0, 0, [ ret ]);
+this._notifySplice(array, path, 0, 0, [ret]);
return ret;
},
-unshift: function(path) {
+unshift: function (path) {
var array = this.get(path);
var args = Array.prototype.slice.call(arguments, 1);
var ret = array.unshift.apply(array, args);
@@ -1729,30 +1738,28 @@ this._notifySplice(array, path, 0, args.length, []);
return ret;
}
});
-})();
-
+}());
Polymer.Base._addFeature({
-resolveUrl: function(url) {
+resolveUrl: function (url) {
var module = Polymer.DomModule.import(this.is);
-var root = "";
+var root = '';
if (module) {
-var assetPath = module.getAttribute("assetpath") || "";
+var assetPath = module.getAttribute('assetpath') || '';
root = Polymer.ResolveUrl.resolveUrl(assetPath, module.ownerDocument.baseURI);
}
return Polymer.ResolveUrl.resolveUrl(url, root);
}
});
-
-Polymer.CssParse = function() {
+Polymer.CssParse = function () {
var api = {
-parse: function(text) {
+parse: function (text) {
text = this._clean(text);
return this._parseCss(this._lex(text), text);
},
-_clean: function(cssText) {
-return cssText.replace(rx.comments, "").replace(rx.port, "");
+_clean: function (cssText) {
+return cssText.replace(rx.comments, '').replace(rx.port, '');
},
-_lex: function(text) {
+_lex: function (text) {
var root = {
start: 0,
end: text.length
@@ -1773,7 +1780,6 @@ previous: previous
};
p.rules.push(n);
break;
-
case this.CLOSE_BRACE:
n.end = i + 1;
n = n.parent || root;
@@ -1782,13 +1788,13 @@ break;
}
return root;
},
-_parseCss: function(node, text) {
+_parseCss: function (node, text) {
var t = text.substring(node.start, node.end - 1);
node.parsedCssText = node.cssText = t.trim();
if (node.parent) {
var ss = node.previous ? node.previous.end : node.parent.start;
t = text.substring(ss, node.start - 1);
-t = t.substring(t.lastIndexOf(";") + 1);
+t = t.substring(t.lastIndexOf(';') + 1);
var s = node.parsedSelector = node.selector = t.trim();
node.atRule = s.indexOf(AT_START) === 0;
if (node.atRule) {
@@ -1813,9 +1819,9 @@ this._parseCss(r, text);
}
return node;
},
-stringify: function(node, preserveProperties, text) {
-text = text || "";
-var cssText = "";
+stringify: function (node, preserveProperties, text) {
+text = text || '';
+var cssText = '';
if (node.cssText || node.rules) {
var r$ = node.rules;
if (r$ && (preserveProperties || !hasMixinRules(r$))) {
@@ -1826,17 +1832,17 @@ cssText = this.stringify(r, preserveProperties, cssText);
cssText = preserveProperties ? node.cssText : removeCustomProps(node.cssText);
cssText = cssText.trim();
if (cssText) {
-cssText = " " + cssText + "\n";
+cssText = ' ' + cssText + '\n';
}
}
}
if (cssText) {
if (node.selector) {
-text += node.selector + " " + this.OPEN_BRACE + "\n";
+text += node.selector + ' ' + this.OPEN_BRACE + '\n';
}
text += cssText;
if (node.selector) {
-text += this.CLOSE_BRACE + "\n\n";
+text += this.CLOSE_BRACE + '\n\n';
}
}
return text;
@@ -1845,20 +1851,20 @@ types: {
STYLE_RULE: 1,
KEYFRAMES_RULE: 7,
MEDIA_RULE: 4,
-MIXIN_RULE: 1e3
+MIXIN_RULE: 1000
},
-OPEN_BRACE: "{",
-CLOSE_BRACE: "}"
+OPEN_BRACE: '{',
+CLOSE_BRACE: '}'
};
function hasMixinRules(rules) {
return rules[0].selector.indexOf(VAR_START) >= 0;
}
function removeCustomProps(cssText) {
-return cssText.replace(rx.customProp, "").replace(rx.mixinProp, "").replace(rx.mixinApply, "").replace(rx.varApply, "");
+return cssText.replace(rx.customProp, '').replace(rx.mixinProp, '').replace(rx.mixinApply, '').replace(rx.varApply, '');
}
-var VAR_START = "--";
-var MEDIA_START = "@media";
-var AT_START = "@";
+var VAR_START = '--';
+var MEDIA_START = '@media';
+var AT_START = '@';
var rx = {
comments: /\/\*[^*]*\*+([^\/*][^*]*\*+)*\//gim,
port: /@import[^;]*;/gim,
@@ -1870,12 +1876,11 @@ keyframesRule: /^@[^\s]*keyframes/
};
return api;
}();
-
-Polymer.StyleUtil = function() {
+Polymer.StyleUtil = function () {
return {
-MODULE_STYLES_SELECTOR: "style, link[rel=import][type~=css]",
-toCssText: function(rules, callback, preserveProperties) {
-if (typeof rules === "string") {
+MODULE_STYLES_SELECTOR: 'style, link[rel=import][type~=css]',
+toCssText: function (rules, callback, preserveProperties) {
+if (typeof rules === 'string') {
rules = this.parser.parse(rules);
}
if (callback) {
@@ -1883,21 +1888,21 @@ this.forEachStyleRule(rules, callback);
}
return this.parser.stringify(rules, preserveProperties);
},
-forRulesInStyles: function(styles, callback) {
+forRulesInStyles: function (styles, callback) {
for (var i = 0, l = styles.length, s; i < l && (s = styles[i]); i++) {
this.forEachStyleRule(this.rulesForStyle(s), callback);
}
},
-rulesForStyle: function(style) {
+rulesForStyle: function (style) {
if (!style.__cssRules) {
style.__cssRules = this.parser.parse(style.textContent);
}
return style.__cssRules;
},
-clearStyleRules: function(style) {
+clearStyleRules: function (style) {
style.__cssRules = null;
},
-forEachStyleRule: function(node, callback) {
+forEachStyleRule: function (node, callback) {
var s = node.selector;
var skipRules = false;
if (node.type === this.ruleTypes.STYLE_RULE) {
@@ -1912,28 +1917,28 @@ this.forEachStyleRule(r, callback);
}
}
},
-applyCss: function(cssText, moniker, target, afterNode) {
-var style = document.createElement("style");
+applyCss: function (cssText, moniker, target, afterNode) {
+var style = document.createElement('style');
if (moniker) {
-style.setAttribute("scope", moniker);
+style.setAttribute('scope', moniker);
}
style.textContent = cssText;
target = target || document.head;
if (!afterNode) {
-var n$ = target.querySelectorAll("style[scope]");
+var n$ = target.querySelectorAll('style[scope]');
afterNode = n$[n$.length - 1];
}
target.insertBefore(style, afterNode && afterNode.nextSibling || target.firstChild);
return style;
},
-cssFromModule: function(moduleId) {
+cssFromModule: function (moduleId) {
var m = Polymer.DomModule.import(moduleId);
if (m && !m._cssText) {
-var cssText = "";
+var cssText = '';
var e$ = Array.prototype.slice.call(m.querySelectorAll(this.MODULE_STYLES_SELECTOR));
for (var i = 0, e; i < e$.length; i++) {
e = e$[i];
-if (e.localName === "style") {
+if (e.localName === 'style') {
e = e.__appliedElement || e;
e.parentNode.removeChild(e);
} else {
@@ -1945,21 +1950,20 @@ cssText += Polymer.ResolveUrl.resolveCss(e.textContent, e.ownerDocument);
}
m._cssText = cssText;
}
-return m && m._cssText || "";
+return m && m._cssText || '';
},
parser: Polymer.CssParse,
ruleTypes: Polymer.CssParse.types
};
}();
-
-Polymer.StyleTransformer = function() {
+Polymer.StyleTransformer = function () {
var nativeShadow = Polymer.Settings.useNativeShadow;
var styleUtil = Polymer.StyleUtil;
var api = {
-dom: function(node, scope, useAttr, shouldRemoveScope) {
-this._transformDom(node, scope || "", useAttr, shouldRemoveScope);
+dom: function (node, scope, useAttr, shouldRemoveScope) {
+this._transformDom(node, scope || '', useAttr, shouldRemoveScope);
},
-_transformDom: function(node, selector, useAttr, shouldRemoveScope) {
+_transformDom: function (node, selector, useAttr, shouldRemoveScope) {
if (node.setAttribute) {
this.element(node, selector, useAttr, shouldRemoveScope);
}
@@ -1968,7 +1972,7 @@ for (var i = 0; i < c$.length; i++) {
this._transformDom(c$[i], selector, useAttr, shouldRemoveScope);
}
},
-element: function(element, scope, useAttr, shouldRemoveScope) {
+element: function (element, scope, useAttr, shouldRemoveScope) {
if (useAttr) {
if (shouldRemoveScope) {
element.removeAttribute(SCOPE_NAME);
@@ -1989,29 +1993,29 @@ element.classList.add(scope);
var c = element.getAttribute(CLASS);
if (shouldRemoveScope) {
if (c) {
-element.setAttribute(CLASS, c.replace(SCOPE_NAME, "").replace(scope, ""));
+element.setAttribute(CLASS, c.replace(SCOPE_NAME, '').replace(scope, ''));
}
} else {
-element.setAttribute(CLASS, c + (c ? " " : "") + SCOPE_NAME + " " + scope);
+element.setAttribute(CLASS, c + (c ? ' ' : '') + SCOPE_NAME + ' ' + scope);
}
}
}
}
},
-elementStyles: function(element, callback) {
+elementStyles: function (element, callback) {
var styles = element._styles;
-var cssText = "";
+var cssText = '';
for (var i = 0, l = styles.length, s, text; i < l && (s = styles[i]); i++) {
var rules = styleUtil.rulesForStyle(s);
-cssText += nativeShadow ? styleUtil.toCssText(rules, callback) : this.css(rules, element.is, element.extends, callback, element._scopeCssViaAttr) + "\n\n";
+cssText += nativeShadow ? styleUtil.toCssText(rules, callback) : this.css(rules, element.is, element.extends, callback, element._scopeCssViaAttr) + '\n\n';
}
return cssText.trim();
},
-css: function(rules, scope, ext, callback, useAttr) {
+css: function (rules, scope, ext, callback, useAttr) {
var hostScope = this._calcHostScope(scope, ext);
scope = this._calcElementScope(scope, useAttr);
var self = this;
-return styleUtil.toCssText(rules, function(rule) {
+return styleUtil.toCssText(rules, function (rule) {
if (!rule.isScoped) {
self.rule(rule, scope, hostScope);
rule.isScoped = true;
@@ -2021,30 +2025,30 @@ callback(rule, scope, hostScope);
}
});
},
-_calcElementScope: function(scope, useAttr) {
+_calcElementScope: function (scope, useAttr) {
if (scope) {
return useAttr ? CSS_ATTR_PREFIX + scope + CSS_ATTR_SUFFIX : CSS_CLASS_PREFIX + scope;
} else {
-return "";
+return '';
}
},
-_calcHostScope: function(scope, ext) {
-return ext ? "[is=" + scope + "]" : scope;
+_calcHostScope: function (scope, ext) {
+return ext ? '[is=' + scope + ']' : scope;
},
-rule: function(rule, scope, hostScope) {
+rule: function (rule, scope, hostScope) {
this._transformRule(rule, this._transformComplexSelector, scope, hostScope);
},
-_transformRule: function(rule, transformer, scope, hostScope) {
+_transformRule: function (rule, transformer, scope, hostScope) {
var p$ = rule.selector.split(COMPLEX_SELECTOR_SEP);
for (var i = 0, l = p$.length, p; i < l && (p = p$[i]); i++) {
p$[i] = transformer.call(this, p, scope, hostScope);
}
rule.selector = p$.join(COMPLEX_SELECTOR_SEP);
},
-_transformComplexSelector: function(selector, scope, hostScope) {
+_transformComplexSelector: function (selector, scope, hostScope) {
var stop = false;
var self = this;
-selector = selector.replace(SIMPLE_SELECTOR_SEP, function(m, c, s) {
+selector = selector.replace(SIMPLE_SELECTOR_SEP, function (m, c, s) {
if (!stop) {
var o = self._transformCompoundSelector(s, c, scope, hostScope);
if (o.stop) {
@@ -2057,10 +2061,10 @@ return c + s;
});
return selector;
},
-_transformCompoundSelector: function(selector, combinator, scope, hostScope) {
+_transformCompoundSelector: function (selector, combinator, scope, hostScope) {
var jumpIndex = selector.search(SCOPE_JUMP);
if (selector.indexOf(HOST) >= 0) {
-selector = selector.replace(HOST_PAREN, function(m, host, paren) {
+selector = selector.replace(HOST_PAREN, function (m, host, paren) {
return hostScope + paren;
});
selector = selector.replace(HOST, hostScope);
@@ -2068,11 +2072,11 @@ selector = selector.replace(HOST, hostScope);
selector = scope ? this._transformSimpleSelector(selector, scope) : selector;
}
if (selector.indexOf(CONTENT) >= 0) {
-combinator = "";
+combinator = '';
}
var stop;
if (jumpIndex >= 0) {
-selector = selector.replace(SCOPE_JUMP, " ");
+selector = selector.replace(SCOPE_JUMP, ' ');
stop = true;
}
return {
@@ -2081,45 +2085,44 @@ combinator: combinator,
stop: stop
};
},
-_transformSimpleSelector: function(selector, scope) {
+_transformSimpleSelector: function (selector, scope) {
var p$ = selector.split(PSEUDO_PREFIX);
p$[0] += scope;
return p$.join(PSEUDO_PREFIX);
},
-rootRule: function(rule) {
+rootRule: function (rule) {
this._transformRule(rule, this._transformRootSelector);
},
-_transformRootSelector: function(selector) {
+_transformRootSelector: function (selector) {
return selector.match(SCOPE_JUMP) ? this._transformComplexSelector(selector) : selector.trim() + SCOPE_ROOT_SELECTOR;
},
-SCOPE_NAME: "style-scope"
+SCOPE_NAME: 'style-scope'
};
var SCOPE_NAME = api.SCOPE_NAME;
-var SCOPE_ROOT_SELECTOR = ":not([" + SCOPE_NAME + "])" + ":not(." + SCOPE_NAME + ")";
-var COMPLEX_SELECTOR_SEP = ",";
+var SCOPE_ROOT_SELECTOR = ':not([' + SCOPE_NAME + '])' + ':not(.' + SCOPE_NAME + ')';
+var COMPLEX_SELECTOR_SEP = ',';
var SIMPLE_SELECTOR_SEP = /(^|[\s>+~]+)([^\s>+~]+)/g;
-var HOST = ":host";
+var HOST = ':host';
var HOST_PAREN = /(\:host)(?:\(((?:\([^)(]*\)|[^)(]*)+?)\))/g;
-var CONTENT = "::content";
+var CONTENT = '::content';
var SCOPE_JUMP = /\:\:content|\:\:shadow|\/deep\//;
-var CSS_CLASS_PREFIX = ".";
-var CSS_ATTR_PREFIX = "[" + SCOPE_NAME + "~=";
-var CSS_ATTR_SUFFIX = "]";
-var PSEUDO_PREFIX = ":";
-var CLASS = "class";
+var CSS_CLASS_PREFIX = '.';
+var CSS_ATTR_PREFIX = '[' + SCOPE_NAME + '~=';
+var CSS_ATTR_SUFFIX = ']';
+var PSEUDO_PREFIX = ':';
+var CLASS = 'class';
return api;
}();
-
-Polymer.StyleExtends = function() {
+Polymer.StyleExtends = function () {
var styleUtil = Polymer.StyleUtil;
return {
-hasExtends: function(cssText) {
+hasExtends: function (cssText) {
return Boolean(cssText.match(this.rx.EXTEND));
},
-transform: function(style) {
+transform: function (style) {
var rules = styleUtil.rulesForStyle(style);
var self = this;
-styleUtil.forEachStyleRule(rules, function(rule) {
+styleUtil.forEachStyleRule(rules, function (rule) {
var map = self._mapRule(rule);
if (rule.parent) {
var m;
@@ -2131,18 +2134,18 @@ self._extendRule(rule, extendor);
}
}
}
-rule.cssText = rule.cssText.replace(self.rx.EXTEND, "");
+rule.cssText = rule.cssText.replace(self.rx.EXTEND, '');
});
-return styleUtil.toCssText(rules, function(rule) {
+return styleUtil.toCssText(rules, function (rule) {
if (rule.selector.match(self.rx.STRIP)) {
-rule.cssText = "";
+rule.cssText = '';
}
}, true);
},
-_mapRule: function(rule) {
+_mapRule: function (rule) {
if (rule.parent) {
var map = rule.parent.map || (rule.parent.map = {});
-var parts = rule.selector.split(",");
+var parts = rule.selector.split(',');
for (var i = 0, p; i < parts.length; i++) {
p = parts[i];
map[p.trim()] = rule;
@@ -2150,24 +2153,24 @@ map[p.trim()] = rule;
return map;
}
},
-_findExtendor: function(extend, rule) {
+_findExtendor: function (extend, rule) {
return rule.parent && rule.parent.map && rule.parent.map[extend] || this._findExtendor(extend, rule.parent);
},
-_extendRule: function(target, source) {
+_extendRule: function (target, source) {
if (target.parent !== source.parent) {
this._cloneAndAddRuleToParent(source, target.parent);
}
target.extends = target.extends || (target.extends = []);
target.extends.push(source);
-source.selector = source.selector.replace(this.rx.STRIP, "");
-source.selector = (source.selector && source.selector + ",\n") + target.selector;
+source.selector = source.selector.replace(this.rx.STRIP, '');
+source.selector = (source.selector && source.selector + ',\n') + target.selector;
if (source.extends) {
-source.extends.forEach(function(e) {
+source.extends.forEach(function (e) {
this._extendRule(target, e);
}, this);
}
},
-_cloneAndAddRuleToParent: function(rule, parent) {
+_cloneAndAddRuleToParent: function (rule, parent) {
rule = Object.create(rule);
rule.parent = parent;
if (rule.extends) {
@@ -2181,21 +2184,20 @@ STRIP: /%[^,]*$/
}
};
}();
-
-(function() {
+(function () {
var prepElement = Polymer.Base._prepElement;
var nativeShadow = Polymer.Settings.useNativeShadow;
var styleUtil = Polymer.StyleUtil;
var styleTransformer = Polymer.StyleTransformer;
var styleExtends = Polymer.StyleExtends;
Polymer.Base._addFeature({
-_prepElement: function(element) {
+_prepElement: function (element) {
if (this._encapsulateStyle) {
styleTransformer.element(element, this.is, this._scopeCssViaAttr);
}
prepElement.call(this, element);
},
-_prepStyles: function() {
+_prepStyles: function () {
if (this._encapsulateStyle === undefined) {
this._encapsulateStyle = !nativeShadow && Boolean(this._template);
}
@@ -2208,9 +2210,9 @@ this._scopeStyle = style;
}
}
},
-_collectStyles: function() {
+_collectStyles: function () {
var styles = [];
-var cssText = "", m$ = this.styleModules;
+var cssText = '', m$ = this.styleModules;
if (m$) {
for (var i = 0, l = m$.length, m; i < l && (m = m$[i]); i++) {
cssText += styleUtil.cssFromModule(m);
@@ -2218,7 +2220,7 @@ cssText += styleUtil.cssFromModule(m);
}
cssText += styleUtil.cssFromModule(this.is);
if (cssText) {
-var style = document.createElement("style");
+var style = document.createElement('style');
style.textContent = cssText;
if (styleExtends.hasExtends(style.textContent)) {
cssText = styleExtends.transform(style);
@@ -2227,34 +2229,38 @@ styles.push(style);
}
return styles;
},
-_elementAdd: function(node) {
-if (this._encapsulateStyle && !node.__styleScoped) {
+_elementAdd: function (node) {
+if (this._encapsulateStyle) {
+if (node.__styleScoped) {
+node.__styleScoped = false;
+} else {
styleTransformer.dom(node, this.is, this._scopeCssViaAttr);
}
+}
},
-_elementRemove: function(node) {
+_elementRemove: function (node) {
if (this._encapsulateStyle) {
styleTransformer.dom(node, this.is, this._scopeCssViaAttr, true);
}
},
-scopeSubtree: function(container, shouldObserve) {
+scopeSubtree: function (container, shouldObserve) {
if (nativeShadow) {
return;
}
var self = this;
-var scopify = function(node) {
+var scopify = function (node) {
if (node.nodeType === Node.ELEMENT_NODE) {
node.className = self._scopeElementClass(node, node.className);
-var n$ = node.querySelectorAll("*");
-Array.prototype.forEach.call(n$, function(n) {
+var n$ = node.querySelectorAll('*');
+Array.prototype.forEach.call(n$, function (n) {
n.className = self._scopeElementClass(n, n.className);
});
}
};
scopify(container);
if (shouldObserve) {
-var mo = new MutationObserver(function(mxns) {
-mxns.forEach(function(m) {
+var mo = new MutationObserver(function (mxns) {
+mxns.forEach(function (m) {
if (m.addedNodes) {
for (var i = 0; i < m.addedNodes.length; i++) {
scopify(m.addedNodes[i]);
@@ -2270,17 +2276,16 @@ return mo;
}
}
});
-})();
-
-Polymer.StyleProperties = function() {
+}());
+Polymer.StyleProperties = function () {
var nativeShadow = Polymer.Settings.useNativeShadow;
var matchesSelector = Polymer.DomApi.matchesSelector;
var styleUtil = Polymer.StyleUtil;
var styleTransformer = Polymer.StyleTransformer;
return {
-decorateStyles: function(styles) {
+decorateStyles: function (styles) {
var self = this, props = {};
-styleUtil.forRulesInStyles(styles, function(rule) {
+styleUtil.forRulesInStyles(styles, function (rule) {
self.decorateRule(rule);
self.collectPropertiesInCssText(rule.propertyInfo.cssText, props);
});
@@ -2290,7 +2295,7 @@ names.push(i);
}
return names;
},
-decorateRule: function(rule) {
+decorateRule: function (rule) {
if (rule.propertyInfo) {
return rule.propertyInfo;
}
@@ -2304,7 +2309,7 @@ info.cssText = this.collectCssText(rule);
rule.propertyInfo = info;
return info;
},
-collectProperties: function(rule, properties) {
+collectProperties: function (rule, properties) {
var info = rule.propertyInfo;
if (info) {
if (info.properties) {
@@ -2322,68 +2327,68 @@ any = true;
return any;
}
},
-collectCssText: function(rule) {
-var customCssText = "";
+collectCssText: function (rule) {
+var customCssText = '';
var cssText = rule.parsedCssText;
-cssText = cssText.replace(this.rx.BRACKETED, "").replace(this.rx.VAR_ASSIGN, "");
-var parts = cssText.split(";");
+cssText = cssText.replace(this.rx.BRACKETED, '').replace(this.rx.VAR_ASSIGN, '');
+var parts = cssText.split(';');
for (var i = 0, p; i < parts.length; i++) {
p = parts[i];
if (p.match(this.rx.MIXIN_MATCH) || p.match(this.rx.VAR_MATCH)) {
-customCssText += p + ";\n";
+customCssText += p + ';\n';
}
}
return customCssText;
},
-collectPropertiesInCssText: function(cssText, props) {
+collectPropertiesInCssText: function (cssText, props) {
var m;
while (m = this.rx.VAR_CAPTURE.exec(cssText)) {
props[m[1]] = true;
}
},
-reify: function(props) {
+reify: function (props) {
var names = Object.getOwnPropertyNames(props);
for (var i = 0, n; i < names.length; i++) {
n = names[i];
props[n] = this.valueForProperty(props[n], props);
}
},
-valueForProperty: function(property, props) {
+valueForProperty: function (property, props) {
if (property) {
-if (property.indexOf(";") >= 0) {
+if (property.indexOf(';') >= 0) {
property = this.valueForProperties(property, props);
} else {
var self = this;
-var fn = function(all, prefix, value, fallback) {
+var fn = function (all, prefix, value, fallback) {
var propertyValue = self.valueForProperty(props[value], props) || (props[fallback] ? self.valueForProperty(props[fallback], props) : fallback);
-return prefix + (propertyValue || "");
+return prefix + (propertyValue || '');
};
property = property.replace(this.rx.VAR_MATCH, fn);
}
}
-return property && property.trim() || "";
+return property && property.trim() || '';
},
-valueForProperties: function(property, props) {
-var parts = property.split(";");
+valueForProperties: function (property, props) {
+var parts = property.split(';');
for (var i = 0, p, m; i < parts.length && (p = parts[i]); i++) {
m = p.match(this.rx.MIXIN_MATCH);
if (m) {
p = this.valueForProperty(props[m[1]], props);
} else {
-var pp = p.split(":");
+var pp = p.split(':');
if (pp[1]) {
pp[1] = pp[1].trim();
pp[1] = this.valueForProperty(pp[1], props) || pp[1];
}
-p = pp.join(":");
+p = pp.join(':');
}
-parts[i] = p && p.lastIndexOf(";") === p.length - 1 ? p.slice(0, -1) : p || "";
+parts[i] = p && p.lastIndexOf(';') === p.length - 1 ? p.slice(0, -1) : p || '';
}
-return parts.join(";");
+return parts.join(';');
},
-applyProperties: function(rule, props) {
-var output = "";
-if (!rule.properties) {
+applyProperties: function (rule, props) {
+var output = '';
+if (!rule.propertyInfo) {
this.decorateRule(rule);
}
if (rule.propertyInfo.cssText) {
@@ -2391,10 +2396,10 @@ output = this.valueForProperties(rule.propertyInfo.cssText, props);
}
rule.cssText = output;
},
-propertyDataFromStyles: function(styles, element) {
+propertyDataFromStyles: function (styles, element) {
var props = {}, self = this;
var o = [], i = 0;
-styleUtil.forRulesInStyles(styles, function(rule) {
+styleUtil.forRulesInStyles(styles, function (rule) {
if (!rule.propertyInfo) {
self.decorateRule(rule);
}
@@ -2409,21 +2414,21 @@ properties: props,
key: o
};
},
-scopePropertiesFromStyles: function(styles) {
+scopePropertiesFromStyles: function (styles) {
if (!styles._scopeStyleProperties) {
styles._scopeStyleProperties = this.selectedPropertiesFromStyles(styles, this.SCOPE_SELECTORS);
}
return styles._scopeStyleProperties;
},
-hostPropertiesFromStyles: function(styles) {
+hostPropertiesFromStyles: function (styles) {
if (!styles._hostStyleProperties) {
styles._hostStyleProperties = this.selectedPropertiesFromStyles(styles, this.HOST_SELECTORS);
}
return styles._hostStyleProperties;
},
-selectedPropertiesFromStyles: function(styles, selectors) {
+selectedPropertiesFromStyles: function (styles, selectors) {
var props = {}, self = this;
-styleUtil.forRulesInStyles(styles, function(rule) {
+styleUtil.forRulesInStyles(styles, function (rule) {
if (!rule.propertyInfo) {
self.decorateRule(rule);
}
@@ -2436,29 +2441,29 @@ return;
});
return props;
},
-transformStyles: function(element, properties, scopeSelector) {
+transformStyles: function (element, properties, scopeSelector) {
var self = this;
var hostRx = new RegExp(this.rx.HOST_PREFIX + element.is + this.rx.HOST_SUFFIX);
-return styleTransformer.elementStyles(element, function(rule) {
+return styleTransformer.elementStyles(element, function (rule) {
self.applyProperties(rule, properties);
if (rule.cssText && !nativeShadow) {
self._scopeSelector(rule, hostRx, element.is, element._scopeCssViaAttr, scopeSelector);
}
});
},
-_scopeSelector: function(rule, hostRx, is, viaAttr, scopeId) {
+_scopeSelector: function (rule, hostRx, is, viaAttr, scopeId) {
rule.transformedSelector = rule.transformedSelector || rule.selector;
var selector = rule.transformedSelector;
-var scope = viaAttr ? "[" + styleTransformer.SCOPE_NAME + "~=" + scopeId + "]" : "." + scopeId;
-var parts = selector.split(",");
+var scope = viaAttr ? '[' + styleTransformer.SCOPE_NAME + '~=' + scopeId + ']' : '.' + scopeId;
+var parts = selector.split(',');
for (var i = 0, l = parts.length, p; i < l && (p = parts[i]); i++) {
-parts[i] = p.match(hostRx) ? p.replace(is, is + scope) : scope + " " + p;
+parts[i] = p.match(hostRx) ? p.replace(is, is + scope) : scope + ' ' + p;
}
-rule.selector = parts.join(",");
+rule.selector = parts.join(',');
},
-applyElementScopeSelector: function(element, selector, old, viaAttr) {
+applyElementScopeSelector: function (element, selector, old, viaAttr) {
var c = viaAttr ? element.getAttribute(styleTransformer.SCOPE_NAME) : element.className;
-v = old ? c.replace(old, selector) : (c ? c + " " : "") + this.XSCOPE_NAME + " " + selector;
+v = old ? c.replace(old, selector) : (c ? c + ' ' : '') + this.XSCOPE_NAME + ' ' + selector;
if (c !== v) {
if (viaAttr) {
element.setAttribute(styleTransformer.SCOPE_NAME, v);
@@ -2467,8 +2472,8 @@ element.className = v;
}
}
},
-applyElementStyle: function(element, properties, selector, style) {
-var cssText = style ? style.textContent || "" : this.transformStyles(element, properties, selector);
+applyElementStyle: function (element, properties, selector, style) {
+var cssText = style ? style.textContent || '' : this.transformStyles(element, properties, selector);
var s = element._customStyle;
if (s && !nativeShadow && s !== style) {
s._useCount--;
@@ -2499,12 +2504,12 @@ MIXIN_MATCH: /(?:^|\W+)@apply[\s]*\(([^)]*)\);?/im,
VAR_MATCH: /(^|\W+)var\([\s]*([^,)]*)[\s]*,?[\s]*((?:[^,)]*)|(?:[^;]*\([^;)]*\)))[\s]*?\)/gim,
VAR_CAPTURE: /\([\s]*(--[^,\s)]*)(?:,[\s]*(--[^,\s)]*))?(?:\)|,)/gim,
BRACKETED: /\{[^}]*\}/g,
-HOST_PREFIX: "(?:^|[^.])",
-HOST_SUFFIX: "($|[.:[\\s>+~])"
+HOST_PREFIX: '(?:^|[^.])',
+HOST_SUFFIX: '($|[.:[\\s>+~])'
},
-HOST_SELECTORS: [ ":host" ],
-SCOPE_SELECTORS: [ ":root" ],
-XSCOPE_NAME: "x-scope"
+HOST_SELECTORS: [':host'],
+SCOPE_SELECTORS: [':root'],
+XSCOPE_NAME: 'x-scope'
};
function addToBitMask(n, bits) {
var o = parseInt(n / 32);
@@ -2512,16 +2517,15 @@ var v = 1 << n % 32;
bits[o] = (bits[o] || 0) | v;
}
}();
-
-Polymer.StyleDefaults = function() {
+Polymer.StyleDefaults = function () {
var styleProperties = Polymer.StyleProperties;
var styleUtil = Polymer.StyleUtil;
-var style = document.createElement("style");
+var style = document.createElement('style');
var api = {
style: style,
-_styles: [ style ],
+_styles: [style],
_properties: null,
-applyCss: function(cssText) {
+applyCss: function (cssText) {
this.style.textContent += cssText;
styleUtil.clearStyleRules(this.style);
this._properties = null;
@@ -2534,21 +2538,21 @@ this._properties = styleProperties.scopePropertiesFromStyles(this._styles);
}
return this._properties;
},
-_needsStyleProperties: function() {},
-_computeStyleProperties: function() {
+_needsStyleProperties: function () {
+},
+_computeStyleProperties: function () {
return this._styleProperties;
}
};
return api;
}();
-
-(function() {
-Polymer.StyleCache = function() {
+(function () {
+Polymer.StyleCache = function () {
this.cache = {};
};
Polymer.StyleCache.prototype = {
MAX: 100,
-store: function(is, data, keyValues, keyStyles) {
+store: function (is, data, keyValues, keyStyles) {
data.keyValues = keyValues;
data.styles = keyStyles;
var s$ = this.cache[is] = this.cache[is] || [];
@@ -2557,7 +2561,7 @@ if (s$.length > this.MAX) {
s$.shift();
}
},
-retrieve: function(is, keyValues, keyStyles) {
+retrieve: function (is, keyValues, keyStyles) {
var cache = this.cache[is];
if (cache) {
for (var i = cache.length - 1, data; i >= 0; i--) {
@@ -2568,10 +2572,10 @@ return data;
}
}
},
-clear: function() {
+clear: function () {
this.cache = {};
},
-_objectsEqual: function(target, source) {
+_objectsEqual: function (target, source) {
for (var i in target) {
if (target[i] !== source[i]) {
return false;
@@ -2583,9 +2587,8 @@ return target.length === source.length;
return true;
}
};
-})();
-
-(function() {
+}());
+(function () {
var serializeValueToAttribute = Polymer.Base.serializeValueToAttribute;
var propertyUtils = Polymer.StyleProperties;
var styleTransformer = Polymer.StyleTransformer;
@@ -2593,21 +2596,21 @@ var styleUtil = Polymer.StyleUtil;
var styleDefaults = Polymer.StyleDefaults;
var nativeShadow = Polymer.Settings.useNativeShadow;
Polymer.Base._addFeature({
-_prepStyleProperties: function() {
+_prepStyleProperties: function () {
this._ownStylePropertyNames = this._styles ? propertyUtils.decorateStyles(this._styles) : [];
},
-_setupStyleProperties: function() {
+_setupStyleProperties: function () {
this.customStyle = {};
},
-_needsStyleProperties: function() {
+_needsStyleProperties: function () {
return Boolean(this._ownStylePropertyNames && this._ownStylePropertyNames.length);
},
-_beforeAttached: function() {
+_beforeAttached: function () {
if (!this._scopeSelector && this._needsStyleProperties()) {
this._updateStyleProperties();
}
},
-_updateStyleProperties: function() {
+_updateStyleProperties: function () {
var info, scope = this.domHost || styleDefaults;
if (!scope._styleCache) {
scope._styleCache = new Polymer.StyleCache();
@@ -2642,7 +2645,7 @@ styleCache.store(this.is, Object.create(info), this._ownStyleProperties, this._s
}
}
},
-_computeStyleProperties: function(scopeProps) {
+_computeStyleProperties: function (scopeProps) {
var scope = this.domHost || styleDefaults;
if (!scope._styleProperties) {
scope._computeStyleProperties();
@@ -2656,7 +2659,7 @@ this.mixin(props, this.customStyle);
propertyUtils.reify(props);
this._styleProperties = props;
},
-_computeOwnStyleProperties: function() {
+_computeOwnStyleProperties: function () {
var props = {};
for (var i = 0, n; i < this._ownStylePropertyNames.length; i++) {
n = this._ownStylePropertyNames[i];
@@ -2665,18 +2668,18 @@ props[n] = this._styleProperties[n];
this._ownStyleProperties = props;
},
_scopeCount: 0,
-_applyStyleProperties: function(info) {
+_applyStyleProperties: function (info) {
var oldScopeSelector = this._scopeSelector;
-this._scopeSelector = info ? info._scopeSelector : this.is + "-" + this.__proto__._scopeCount++;
+this._scopeSelector = info ? info._scopeSelector : this.is + '-' + this.__proto__._scopeCount++;
style = propertyUtils.applyElementStyle(this, this._styleProperties, this._scopeSelector, info && info.style);
if ((style || oldScopeSelector) && !nativeShadow) {
propertyUtils.applyElementScopeSelector(this, this._scopeSelector, oldScopeSelector, this._scopeCssViaAttr);
}
return style || {};
},
-serializeValueToAttribute: function(value, attribute, node) {
+serializeValueToAttribute: function (value, attribute, node) {
node = node || this;
-if (attribute === "class") {
+if (attribute === 'class') {
var host = node === this ? this.domHost || this.dataHost : this;
if (host) {
value = host._scopeElementClass(node, value);
@@ -2685,13 +2688,13 @@ value = host._scopeElementClass(node, value);
node = Polymer.dom(node);
serializeValueToAttribute.call(this, value, attribute, node);
},
-_scopeElementClass: function(element, selector) {
+_scopeElementClass: function (element, selector) {
if (!nativeShadow && !this._scopeCssViaAttr) {
-selector += (selector ? " " : "") + SCOPE_NAME + " " + this.is + (element._scopeSelector ? " " + XSCOPE_NAME + " " + element._scopeSelector : "");
+selector += (selector ? ' ' : '') + SCOPE_NAME + ' ' + this.is + (element._scopeSelector ? ' ' + XSCOPE_NAME + ' ' + element._scopeSelector : '');
}
return selector;
},
-updateStyles: function() {
+updateStyles: function () {
if (this.isAttached) {
if (this._needsStyleProperties()) {
this._updateStyleProperties();
@@ -2704,9 +2707,9 @@ this._styleCache.clear();
this._updateRootStyles();
}
},
-_updateRootStyles: function(root) {
+_updateRootStyles: function (root) {
root = root || this.root;
-var c$ = Polymer.dom(root)._query(function(e) {
+var c$ = Polymer.dom(root)._query(function (e) {
return e.shadyRoot || e.shadowRoot;
});
for (var i = 0, l = c$.length, c; i < l && (c = c$[i]); i++) {
@@ -2716,7 +2719,7 @@ c.updateStyles();
}
}
});
-Polymer.updateStyles = function() {
+Polymer.updateStyles = function () {
styleDefaults._styleCache.clear();
Polymer.Base._updateRootStyles(document);
};
@@ -2724,10 +2727,9 @@ var styleCache = new Polymer.StyleCache();
Polymer.customStyleCache = styleCache;
var SCOPE_NAME = styleTransformer.SCOPE_NAME;
var XSCOPE_NAME = propertyUtils.XSCOPE_NAME;
-})();
-
+}());
Polymer.Base._addFeature({
-_registerFeatures: function() {
+_registerFeatures: function () {
this._prepIs();
this._prepAttributes();
this._prepExtends();
@@ -2741,12 +2743,12 @@ this._prepBehaviors();
this._prepBindings();
this._prepShady();
},
-_prepBehavior: function(b) {
+_prepBehavior: function (b) {
this._addPropertyEffects(b.properties);
this._addComplexObserverEffects(b.observers);
this._addHostAttributes(b.hostAttributes);
},
-_initFeatures: function() {
+_initFeatures: function () {
this._poolContent();
this._setupConfigure();
this._setupStyleProperties();
@@ -2761,41 +2763,40 @@ this._marshalBehaviors();
this._marshalAttributes();
this._tryReady();
},
-_marshalBehavior: function(b) {
+_marshalBehavior: function (b) {
this._listenListeners(b.listeners);
}
});
-
-(function() {
+(function () {
var nativeShadow = Polymer.Settings.useNativeShadow;
var propertyUtils = Polymer.StyleProperties;
var styleUtil = Polymer.StyleUtil;
var styleDefaults = Polymer.StyleDefaults;
Polymer({
-is: "custom-style",
-"extends": "style",
-created: function() {
-this._appliesToDocument = this.parentNode.localName !== "dom-module";
+is: 'custom-style',
+extends: 'style',
+created: function () {
+this._appliesToDocument = this.parentNode.localName !== 'dom-module';
if (this._appliesToDocument) {
var e = this.__appliedElement || this;
var rules = styleUtil.rulesForStyle(e);
-propertyUtils.decorateStyles([ e ]);
+propertyUtils.decorateStyles([e]);
this._rulesToDefaultProperties(rules);
this.async(this._applyStyle);
}
},
-_applyStyle: function() {
+_applyStyle: function () {
var e = this.__appliedElement || this;
this._computeStyleProperties();
var props = this._styleProperties;
var self = this;
-e.textContent = styleUtil.toCssText(styleUtil.rulesForStyle(e), function(rule) {
-if (rule.selector === ":root") {
-rule.selector = "body";
+e.textContent = styleUtil.toCssText(styleUtil.rulesForStyle(e), function (rule) {
+if (rule.selector === ':root') {
+rule.selector = 'body';
}
var css = rule.cssText = rule.parsedCssText;
-if (rule.propertyInfo.cssText) {
-css = css.replace(propertyUtils.rx.VAR_ASSIGN, "");
+if (rule.propertyInfo && rule.propertyInfo.cssText) {
+css = css.replace(propertyUtils.rx.VAR_ASSIGN, '');
rule.cssText = propertyUtils.valueForProperties(css, props);
}
if (!nativeShadow) {
@@ -2803,10 +2804,10 @@ Polymer.StyleTransformer.rootRule(rule);
}
});
},
-_rulesToDefaultProperties: function(rules) {
-styleUtil.forEachStyleRule(rules, function(rule) {
+_rulesToDefaultProperties: function (rules) {
+styleUtil.forEachStyleRule(rules, function (rule) {
if (!rule.propertyInfo.properties) {
-rule.cssText = "";
+rule.cssText = '';
}
});
var cssText = styleUtil.parser.stringify(rules, true);
@@ -2815,24 +2816,19 @@ styleDefaults.applyCss(cssText);
}
}
});
-})();
-
+}());
Polymer.Templatizer = {
-properties: {
-_hideTemplateChildren: {
-observer: "_hideTemplateChildrenChanged"
-}
-},
+properties: { _hideTemplateChildren: { observer: '_showHideChildren' } },
_templatizerStatic: {
count: 0,
callbacks: {},
debouncer: null
},
_instanceProps: Polymer.nob,
-created: function() {
+created: function () {
this._templatizerId = this._templatizerStatic.count++;
},
-templatize: function(template) {
+templatize: function (template) {
if (!template._content) {
template._content = template.content;
}
@@ -2860,19 +2856,16 @@ archetype.constructor = ctor;
template._content._ctor = ctor;
this.ctor = ctor;
},
-_getRootDataHost: function() {
+_getRootDataHost: function () {
return this.dataHost && this.dataHost._rootDataHost || this.dataHost;
},
-_hideTemplateChildrenChanged: function(hidden) {
-if (this._hideChildren) {
-this._hideChildren(hidden);
-}
+_showHideChildren: function (hidden) {
},
-_debounceTemplate: function(fn) {
+_debounceTemplate: function (fn) {
this._templatizerStatic.callbacks[this._templatizerId] = fn.bind(this);
this._templatizerStatic.debouncer = Polymer.Debounce(this._templatizerStatic.debouncer, this._flushTemplates.bind(this, true));
},
-_flushTemplates: function(debouncerExpired) {
+_flushTemplates: function (debouncerExpired) {
var db = this._templatizerStatic.debouncer;
while (debouncerExpired || db && db.finish) {
db.stop();
@@ -2884,13 +2877,13 @@ cbs[id]();
debouncerExpired = false;
}
},
-_customPrepEffects: function(archetype) {
+_customPrepEffects: function (archetype) {
var parentProps = archetype._parentProps;
for (var prop in parentProps) {
-archetype._addPropertyEffect(prop, "function", this._createHostPropEffector(prop));
+archetype._addPropertyEffect(prop, 'function', this._createHostPropEffector(prop));
}
},
-_customPrepAnnotations: function(archetype, template) {
+_customPrepAnnotations: function (archetype, template) {
archetype._template = template;
var c = template._content;
if (!c._notes) {
@@ -2905,7 +2898,7 @@ this._processAnnotations(c._notes);
archetype._notes = c._notes;
archetype._parentProps = c._parentProps;
},
-_prepParentProperties: function(archetype, template) {
+_prepParentProperties: function (archetype, template) {
var parentProps = this._parentProps = archetype._parentProps;
if (this._forwardParentProp && parentProps) {
var proto = archetype._parentPropProto;
@@ -2919,13 +2912,14 @@ if (template != this) {
Polymer.Bind.prepareModel(proto);
}
for (prop in parentProps) {
-var parentProp = "_parent_" + prop;
-var effects = [ {
-kind: "function",
+var parentProp = '_parent_' + prop;
+var effects = [
+{
+kind: 'function',
effect: this._createForwardPropEffector(prop)
-}, {
-kind: "notify"
-} ];
+},
+{ kind: 'notify' }
+];
Polymer.Bind._createAccessors(proto, parentProp, effects);
}
}
@@ -2936,18 +2930,18 @@ template._forwardParentProp = this._forwardParentProp.bind(this);
this._extendTemplate(template, proto);
}
},
-_createForwardPropEffector: function(prop) {
-return function(source, value) {
+_createForwardPropEffector: function (prop) {
+return function (source, value) {
this._forwardParentProp(prop, value);
};
},
-_createHostPropEffector: function(prop) {
-return function(source, value) {
-this.dataHost["_parent_" + prop] = value;
+_createHostPropEffector: function (prop) {
+return function (source, value) {
+this.dataHost['_parent_' + prop] = value;
};
},
-_extendTemplate: function(template, proto) {
-Object.getOwnPropertyNames(proto).forEach(function(n) {
+_extendTemplate: function (template, proto) {
+Object.getOwnPropertyNames(proto).forEach(function (n) {
var val = template[n];
var pd = Object.getOwnPropertyDescriptor(proto, n);
Object.defineProperty(template, n, pd);
@@ -2956,25 +2950,26 @@ template._propertySet(n, val);
}
});
},
-_forwardInstancePath: function(inst, path, value) {},
-_notifyPathImpl: function(path, value) {
+_forwardInstancePath: function (inst, path, value) {
+},
+_notifyPathImpl: function (path, value) {
var dataHost = this.dataHost;
-var dot = path.indexOf(".");
+var dot = path.indexOf('.');
var root = dot < 0 ? path : path.slice(0, dot);
dataHost._forwardInstancePath.call(dataHost, this, path, value);
if (root in dataHost._parentProps) {
-dataHost.notifyPath("_parent_" + path, value);
+dataHost.notifyPath('_parent_' + path, value);
}
},
-_pathEffector: function(path, value, fromAbove) {
+_pathEffector: function (path, value, fromAbove) {
if (this._forwardParentPath) {
-if (path.indexOf("_parent_") === 0) {
+if (path.indexOf('_parent_') === 0) {
this._forwardParentPath(path.substring(8), value);
}
}
Polymer.Base._pathEffector.apply(this, arguments);
},
-_constructorImpl: function(model, host) {
+_constructorImpl: function (model, host) {
this._rootDataHost = host._getRootDataHost();
this._setupConfigure(model);
this._pushHost(host);
@@ -2992,115 +2987,111 @@ n._templateInstance = this;
this._children = children;
this._tryReady();
},
-_listenImpl: function(node, eventName, methodName) {
+_listenImpl: function (node, eventName, methodName) {
var model = this;
var host = this._rootDataHost;
var handler = host._createEventHandler(node, eventName, methodName);
-var decorated = function(e) {
+var decorated = function (e) {
e.model = model;
handler(e);
};
host._listen(node, eventName, decorated);
},
-_scopeElementClassImpl: function(node, value) {
+_scopeElementClassImpl: function (node, value) {
var host = this._rootDataHost;
if (host) {
return host._scopeElementClass(node, value);
}
},
-stamp: function(model) {
+stamp: function (model) {
model = model || {};
if (this._parentProps) {
for (var prop in this._parentProps) {
-model[prop] = this["_parent_" + prop];
+model[prop] = this['_parent_' + prop];
}
}
return new this.ctor(model, this);
}
};
-
Polymer({
-is: "dom-template",
-"extends": "template",
-behaviors: [ Polymer.Templatizer ],
-ready: function() {
+is: 'dom-template',
+extends: 'template',
+behaviors: [Polymer.Templatizer],
+ready: function () {
this.templatize(this);
}
});
-
Polymer._collections = new WeakMap();
-
-Polymer.Collection = function(userArray) {
+Polymer.Collection = function (userArray) {
Polymer._collections.set(userArray, this);
this.userArray = userArray;
this.store = userArray.slice();
this.initMap();
};
-
Polymer.Collection.prototype = {
constructor: Polymer.Collection,
-initMap: function() {
+initMap: function () {
var omap = this.omap = new WeakMap();
var pmap = this.pmap = {};
var s = this.store;
for (var i = 0; i < s.length; i++) {
var item = s[i];
-if (item && typeof item == "object") {
+if (item && typeof item == 'object') {
omap.set(item, i);
} else {
pmap[item] = i;
}
}
},
-add: function(item) {
+add: function (item) {
var key = this.store.push(item) - 1;
-if (item && typeof item == "object") {
+if (item && typeof item == 'object') {
this.omap.set(item, key);
} else {
this.pmap[item] = key;
}
return key;
},
-removeKey: function(key) {
+removeKey: function (key) {
this._removeFromMap(this.store[key]);
delete this.store[key];
},
-_removeFromMap: function(item) {
-if (typeof item == "object") {
+_removeFromMap: function (item) {
+if (typeof item == 'object') {
this.omap.delete(item);
} else {
delete this.pmap[item];
}
},
-remove: function(item) {
+remove: function (item) {
var key = this.getKey(item);
this.removeKey(key);
return key;
},
-getKey: function(item) {
-if (typeof item == "object") {
+getKey: function (item) {
+if (typeof item == 'object') {
return this.omap.get(item);
} else {
return this.pmap[item];
}
},
-getKeys: function() {
+getKeys: function () {
return Object.keys(this.store);
},
-setItem: function(key, value) {
+setItem: function (key, value) {
this.store[key] = value;
},
-getItem: function(key) {
+getItem: function (key) {
return this.store[key];
},
-getItems: function() {
+getItems: function () {
var items = [], store = this.store;
for (var key in store) {
items.push(store[key]);
}
return items;
},
-applySplices: function(splices) {
+applySplices: function (splices) {
var keySplices = [];
for (var i = 0; i < splices.length; i++) {
var j, o, key, s = splices[i];
@@ -3126,64 +3117,65 @@ added: added
return keySplices;
}
};
-
-Polymer.Collection.get = function(userArray) {
+Polymer.Collection.get = function (userArray) {
return Polymer._collections.get(userArray) || new Polymer.Collection(userArray);
};
-
Polymer({
-is: "dom-repeat",
-"extends": "template",
+is: 'dom-repeat',
+extends: 'template',
properties: {
-items: {
-type: Array
-},
+items: { type: Array },
as: {
type: String,
-value: "item"
+value: 'item'
},
indexAs: {
type: String,
-value: "index"
+value: 'index'
},
sort: {
type: Function,
-observer: "_sortChanged"
+observer: '_sortChanged'
},
filter: {
type: Function,
-observer: "_filterChanged"
+observer: '_filterChanged'
},
observe: {
type: String,
-observer: "_observeChanged"
+observer: '_observeChanged'
},
delay: Number
},
-behaviors: [ Polymer.Templatizer ],
-observers: [ "_itemsChanged(items.*)" ],
-detached: function() {
+behaviors: [Polymer.Templatizer],
+observers: ['_itemsChanged(items.*)'],
+detached: function () {
if (this.rows) {
for (var i = 0; i < this.rows.length; i++) {
this._detachRow(i);
}
}
-this.rows = null;
},
-ready: function() {
-this._instanceProps = {
-__key__: true
-};
+attached: function () {
+if (this.rows) {
+var parentNode = Polymer.dom(this).parentNode;
+for (var i = 0; i < this.rows.length; i++) {
+Polymer.dom(parentNode).insertBefore(this.rows[i].root, this);
+}
+}
+},
+ready: function () {
+this._instanceProps = { __key__: true };
this._instanceProps[this.as] = true;
this._instanceProps[this.indexAs] = true;
if (!this.ctor) {
this.templatize(this);
}
},
-_sortChanged: function() {
+_sortChanged: function () {
var dataHost = this._getRootDataHost();
var sort = this.sort;
-this._sortFn = sort && (typeof sort == "function" ? sort : function() {
+this._sortFn = sort && (typeof sort == 'function' ? sort : function () {
return dataHost[sort].apply(dataHost, arguments);
});
this._fullRefresh = true;
@@ -3191,10 +3183,10 @@ if (this.items) {
this._debounceTemplate(this._render);
}
},
-_filterChanged: function() {
+_filterChanged: function () {
var dataHost = this._getRootDataHost();
var filter = this.filter;
-this._filterFn = filter && (typeof filter == "function" ? filter : function() {
+this._filterFn = filter && (typeof filter == 'function' ? filter : function () {
return dataHost[filter].apply(dataHost, arguments);
});
this._fullRefresh = true;
@@ -3202,22 +3194,22 @@ if (this.items) {
this._debounceTemplate(this._render);
}
},
-_observeChanged: function() {
-this._observePaths = this.observe && this.observe.replace(".*", ".").split(" ");
+_observeChanged: function () {
+this._observePaths = this.observe && this.observe.replace('.*', '.').split(' ');
},
-_itemsChanged: function(change) {
-if (change.path == "items") {
+_itemsChanged: function (change) {
+if (change.path == 'items') {
if (Array.isArray(this.items)) {
this.collection = Polymer.Collection.get(this.items);
} else if (!this.items) {
this.collection = null;
} else {
-this._error(this._logf("dom-repeat", "expected array for `items`," + " found", this.items));
+this._error(this._logf('dom-repeat', 'expected array for `items`,' + ' found', this.items));
}
this._splices = [];
this._fullRefresh = true;
this._debounceTemplate(this._render);
-} else if (change.path == "items.splices") {
+} else if (change.path == 'items.splices') {
this._splices = this._splices.concat(change.value.keySplices);
this._debounceTemplate(this._render);
} else {
@@ -3226,15 +3218,15 @@ this._forwardItemPath(subpath, change.value);
this._checkObservedPaths(subpath);
}
},
-_checkObservedPaths: function(path) {
+_checkObservedPaths: function (path) {
if (this._observePaths) {
-path = path.substring(path.indexOf(".") + 1);
+path = path.substring(path.indexOf('.') + 1);
var paths = this._observePaths;
for (var i = 0; i < paths.length; i++) {
if (path.indexOf(paths[i]) === 0) {
this._fullRefresh = true;
if (this.delay) {
-this.debounce("render", this._render, this.delay);
+this.debounce('render', this._render, this.delay);
} else {
this._debounceTemplate(this._render);
}
@@ -3243,12 +3235,12 @@ return;
}
}
},
-render: function() {
+render: function () {
this._fullRefresh = true;
-this.debounce("render", this._render);
+this.debounce('render', this._render);
this._flushTemplates();
},
-_render: function() {
+_render: function () {
var c = this.collection;
if (!this._fullRefresh) {
if (this._sortFn) {
@@ -3281,13 +3273,13 @@ row[this.as] = item;
row.__key__ = key;
row[this.indexAs] = i;
}
-for (;i < this.rows.length; i++) {
+for (; i < this.rows.length; i++) {
this._detachRow(i);
}
this.rows.splice(keys.length, this.rows.length - keys.length);
-this.fire("dom-change");
+this.fire('dom-change');
},
-_sortAndFilter: function() {
+_sortAndFilter: function () {
var c = this.collection;
if (!this._sortFn) {
this._orderedKeys = [];
@@ -3301,20 +3293,20 @@ this._orderedKeys.push(c.getKey(items[i]));
this._orderedKeys = c ? c.getKeys() : [];
}
if (this._filterFn) {
-this._orderedKeys = this._orderedKeys.filter(function(a) {
+this._orderedKeys = this._orderedKeys.filter(function (a) {
return this._filterFn(c.getItem(a));
}, this);
}
if (this._sortFn) {
-this._orderedKeys.sort(function(a, b) {
+this._orderedKeys.sort(function (a, b) {
return this._sortFn(c.getItem(a), c.getItem(b));
}.bind(this));
}
},
-_keySort: function(a, b) {
+_keySort: function (a, b) {
return this.collection.getKey(a) - this.collection.getKey(b);
},
-_applySplicesViewSort: function(splices) {
+_applySplicesViewSort: function (splices) {
var c = this.collection;
var keys = this._orderedKeys;
var rows = this.rows;
@@ -3322,7 +3314,7 @@ var removedRows = [];
var addedKeys = [];
var pool = [];
var sortFn = this._sortFn || this._keySort.bind(this);
-splices.forEach(function(s) {
+splices.forEach(function (s) {
for (var i = 0; i < s.removed.length; i++) {
var idx = this._rowForKey[s.removed[i]];
if (idx != null) {
@@ -3344,11 +3336,11 @@ keys.splice(idx, 1);
}
if (addedKeys.length) {
if (this._filterFn) {
-addedKeys = addedKeys.filter(function(a) {
+addedKeys = addedKeys.filter(function (a) {
return this._filterFn(c.getItem(a));
}, this);
}
-addedKeys.sort(function(a, b) {
+addedKeys.sort(function (a, b) {
return this._sortFn(c.getItem(a), c.getItem(b));
}.bind(this));
var start = 0;
@@ -3357,7 +3349,7 @@ start = this._insertRowIntoViewSort(start, addedKeys[i], pool);
}
}
},
-_insertRowIntoViewSort: function(start, key, pool) {
+_insertRowIntoViewSort: function (start, key, pool) {
var c = this.collection;
var item = c.getItem(key);
var end = this.rows.length - 1;
@@ -3383,18 +3375,21 @@ this._orderedKeys.splice(idx, 0, key);
this.rows.splice(idx, 0, this._insertRow(idx, pool, c.getItem(key)));
return idx;
},
-_applySplicesArraySort: function(splices) {
+_applySplicesArraySort: function (splices) {
var keys = this._orderedKeys;
var pool = [];
-splices.forEach(function(s) {
+splices.forEach(function (s) {
for (var i = 0; i < s.removed.length; i++) {
pool.push(this._detachRow(s.index + i));
}
this.rows.splice(s.index, s.removed.length);
}, this);
var c = this.collection;
-splices.forEach(function(s) {
-var args = [ s.index, s.removed.length ].concat(s.added);
+splices.forEach(function (s) {
+var args = [
+s.index,
+s.removed.length
+].concat(s.added);
keys.splice.apply(keys, args);
for (var i = 0; i < s.added.length; i++) {
var item = c.getItem(s.added[i]);
@@ -3403,7 +3398,7 @@ this.rows.splice(s.index + i, 0, row);
}
}, this);
},
-_detachRow: function(idx) {
+_detachRow: function (idx) {
var row = this.rows[idx];
var parentNode = Polymer.dom(this).parentNode;
for (var i = 0; i < row._children.length; i++) {
@@ -3412,7 +3407,7 @@ Polymer.dom(row.root).appendChild(el);
}
return row;
},
-_insertRow: function(idx, pool, item) {
+_insertRow: function (idx, pool, item) {
var row = pool && pool.pop() || this._generateRow(idx, item);
var beforeRow = this.rows[idx];
var beforeNode = beforeRow ? beforeRow._children[0] : this;
@@ -3420,58 +3415,56 @@ var parentNode = Polymer.dom(this).parentNode;
Polymer.dom(parentNode).insertBefore(row.root, beforeNode);
return row;
},
-_generateRow: function(idx, item) {
-var model = {
-__key__: this.collection.getKey(item)
-};
+_generateRow: function (idx, item) {
+var model = { __key__: this.collection.getKey(item) };
model[this.as] = item;
model[this.indexAs] = idx;
var row = this.stamp(model);
return row;
},
-_hideChildren: function(hidden) {
+_showHideChildren: function (hidden) {
if (this.rows) {
for (var i = 0; i < this.rows.length; i++) {
var c$ = this.rows[i]._children;
for (var j = 0; j < c$.length; j++) {
var c = c$[j];
if (c.style) {
-c.style.display = hidden ? "none" : "";
+c.style.display = hidden ? 'none' : '';
}
c._hideTemplateChildren = hidden;
}
}
}
},
-_forwardInstancePath: function(row, path, value) {
-if (path.indexOf(this.as + ".") === 0) {
-this.notifyPath("items." + row.__key__ + "." + path.slice(this.as.length + 1), value);
+_forwardInstancePath: function (row, path, value) {
+if (path.indexOf(this.as + '.') === 0) {
+this.notifyPath('items.' + row.__key__ + '.' + path.slice(this.as.length + 1), value);
return true;
}
},
-_forwardParentProp: function(prop, value) {
+_forwardParentProp: function (prop, value) {
if (this.rows) {
-this.rows.forEach(function(row) {
+this.rows.forEach(function (row) {
row[prop] = value;
}, this);
}
},
-_forwardParentPath: function(path, value) {
+_forwardParentPath: function (path, value) {
if (this.rows) {
-this.rows.forEach(function(row) {
+this.rows.forEach(function (row) {
row.notifyPath(path, value, true);
}, this);
}
},
-_forwardItemPath: function(path, value) {
+_forwardItemPath: function (path, value) {
if (this._rowForKey) {
-var dot = path.indexOf(".");
+var dot = path.indexOf('.');
var key = path.substring(0, dot < 0 ? path.length : dot);
var idx = this._rowForKey[key];
var row = this.rows[idx];
if (row) {
if (dot >= 0) {
-path = this.as + "." + path.substring(dot + 1);
+path = this.as + '.' + path.substring(dot + 1);
row.notifyPath(path, value, true);
} else {
row[this.as] = value;
@@ -3479,7 +3472,7 @@ row[this.as] = value;
}
}
},
-modelForElement: function(el) {
+modelForElement: function (el) {
var model;
while (el) {
if (model = el._templateInstance) {
@@ -3493,26 +3486,25 @@ el = el.parentNode;
}
}
},
-itemForElement: function(el) {
+itemForElement: function (el) {
var instance = this.modelForElement(el);
return instance && instance[this.as];
},
-keyForElement: function(el) {
+keyForElement: function (el) {
var instance = this.modelForElement(el);
return instance && instance.__key__;
},
-indexForElement: function(el) {
+indexForElement: function (el) {
var instance = this.modelForElement(el);
return instance && instance[this.indexAs];
}
});
-
Polymer({
-is: "array-selector",
+is: 'array-selector',
properties: {
items: {
type: Array,
-observer: "_itemsChanged"
+observer: '_itemsChanged'
},
selected: {
type: Object,
@@ -3521,13 +3513,13 @@ notify: true
toggle: Boolean,
multi: Boolean
},
-_itemsChanged: function() {
+_itemsChanged: function () {
if (Array.isArray(this.selected)) {
for (var i = 0; i < this.selected.length; i++) {
-this.unlinkPaths("selected." + i);
+this.unlinkPaths('selected.' + i);
}
} else {
-this.unlinkPaths("selected");
+this.unlinkPaths('selected');
}
if (this.multi) {
this.selected = [];
@@ -3535,22 +3527,22 @@ this.selected = [];
this.selected = null;
}
},
-deselect: function(item) {
+deselect: function (item) {
if (this.multi) {
var scol = Polymer.Collection.get(this.selected);
var sidx = this.selected.indexOf(item);
if (sidx >= 0) {
var skey = scol.getKey(item);
-this.splice("selected", sidx, 1);
-this.unlinkPaths("selected." + skey);
+this.splice('selected', sidx, 1);
+this.unlinkPaths('selected.' + skey);
return true;
}
} else {
this.selected = null;
-this.unlinkPaths("selected");
+this.unlinkPaths('selected');
}
},
-select: function(item) {
+select: function (item) {
var icol = Polymer.Collection.get(this.items);
var key = icol.getKey(item);
if (this.multi) {
@@ -3559,28 +3551,27 @@ var skey = scol.getKey(item);
if (skey >= 0) {
this.deselect(item);
} else if (this.toggle) {
-this.push("selected", item);
-this.async(function() {
+this.push('selected', item);
+this.async(function () {
skey = scol.getKey(item);
-this.linkPaths("selected." + skey, "items." + key);
+this.linkPaths('selected.' + skey, 'items.' + key);
});
}
} else {
if (this.toggle && item == this.selected) {
this.deselect();
} else {
-this.linkPaths("selected", "items." + key);
+this.linkPaths('selected', 'items.' + key);
this.selected = item;
}
}
}
});
-
Polymer({
-is: "dom-if",
-"extends": "template",
+is: 'dom-if',
+extends: 'template',
properties: {
-"if": {
+'if': {
type: Boolean,
value: false
},
@@ -3589,42 +3580,42 @@ type: Boolean,
value: false
}
},
-behaviors: [ Polymer.Templatizer ],
-observers: [ "_queueRender(if, restamp)" ],
-_queueRender: function() {
+behaviors: [Polymer.Templatizer],
+observers: ['_queueRender(if, restamp)'],
+_queueRender: function () {
this._debounceTemplate(this._render);
},
-detached: function() {
+detached: function () {
this._teardownInstance();
},
-attached: function() {
+attached: function () {
if (this.if && this.ctor) {
this.async(this._ensureInstance);
}
},
-render: function() {
+render: function () {
this._flushTemplates();
},
-_render: function() {
+_render: function () {
if (this.if) {
if (!this.ctor) {
this._wrapTextNodes(this._content || this.content);
this.templatize(this);
}
this._ensureInstance();
-this._hideTemplateChildren = false;
+this._showHideChildren();
} else if (this.restamp) {
this._teardownInstance();
}
if (!this.restamp && this._instance) {
-this._hideTemplateChildren = !this.if;
+this._showHideChildren();
}
if (this.if != this._lastIf) {
-this.fire("dom-change");
+this.fire('dom-change');
this._lastIf = this.if;
}
},
-_ensureInstance: function() {
+_ensureInstance: function () {
if (!this._instance) {
this._instance = this.stamp();
var root = this._instance.root;
@@ -3632,116 +3623,114 @@ var parent = Polymer.dom(Polymer.dom(this).parentNode);
parent.insertBefore(root, this);
}
},
-_teardownInstance: function() {
+_teardownInstance: function () {
if (this._instance) {
var c = this._instance._children;
if (c) {
var parent = Polymer.dom(Polymer.dom(c[0]).parentNode);
-c.forEach(function(n) {
+c.forEach(function (n) {
parent.removeChild(n);
});
}
this._instance = null;
}
},
-_wrapTextNodes: function(root) {
+_wrapTextNodes: function (root) {
for (var n = root.firstChild; n; n = n.nextSibling) {
if (n.nodeType === Node.TEXT_NODE) {
-var s = document.createElement("span");
+var s = document.createElement('span');
root.insertBefore(s, n);
s.appendChild(n);
n = s;
}
}
},
-_hideChildren: function(hidden) {
+_showHideChildren: function () {
+var hidden = this._hideTemplateChildren || !this.if;
if (this._instance) {
var c$ = this._instance._children;
for (var i = 0; i < c$.length; i++) {
var c = c$[i];
-c.style.display = hidden ? "none" : "";
+c.style.display = hidden ? 'none' : '';
c._hideTemplateChildren = hidden;
}
}
},
-_forwardParentProp: function(prop, value) {
+_forwardParentProp: function (prop, value) {
if (this._instance) {
this._instance[prop] = value;
}
},
-_forwardParentPath: function(path, value) {
+_forwardParentPath: function (path, value) {
if (this._instance) {
this._instance.notifyPath(path, value, true);
}
}
});
-
Polymer.ImportStatus = {
_ready: false,
_callbacks: [],
-whenLoaded: function(cb) {
+whenLoaded: function (cb) {
if (this._ready) {
cb();
} else {
this._callbacks.push(cb);
}
},
-_importsLoaded: function() {
+_importsLoaded: function () {
this._ready = true;
-this._callbacks.forEach(function(cb) {
+this._callbacks.forEach(function (cb) {
cb();
});
this._callbacks = [];
}
};
-
-window.addEventListener("load", function() {
+window.addEventListener('load', function () {
Polymer.ImportStatus._importsLoaded();
});
-
if (window.HTMLImports) {
-HTMLImports.whenReady(function() {
+HTMLImports.whenReady(function () {
Polymer.ImportStatus._importsLoaded();
});
}
-
Polymer({
-is: "dom-bind",
-"extends": "template",
-created: function() {
+is: 'dom-bind',
+extends: 'template',
+created: function () {
Polymer.ImportStatus.whenLoaded(this._readySelf.bind(this));
},
-_registerFeatures: function() {
+_registerFeatures: function () {
this._prepExtends();
this._prepConstructor();
},
-_insertChildren: function() {
+_insertChildren: function () {
var parentDom = Polymer.dom(Polymer.dom(this).parentNode);
parentDom.insertBefore(this.root, this);
},
-_removeChildren: function() {
+_removeChildren: function () {
if (this._children) {
for (var i = 0; i < this._children.length; i++) {
this.root.appendChild(this._children[i]);
}
}
},
-_initFeatures: function() {},
-_scopeElementClass: function(element, selector) {
+_initFeatures: function () {
+},
+_scopeElementClass: function (element, selector) {
if (this.dataHost) {
return this.dataHost._scopeElementClass(element, selector);
} else {
return selector;
}
},
-_prepConfigure: function() {
+_prepConfigure: function () {
var config = {};
for (var prop in this._propertyEffects) {
config[prop] = this[prop];
}
this._setupConfigure = this._setupConfigure.bind(this, config);
},
-attached: function() {
+attached: function () {
if (!this._children) {
this._template = this;
this._prepAnnotations();
@@ -3753,9 +3742,9 @@ Polymer.Base._initFeatures.call(this);
this._children = Array.prototype.slice.call(this.root.childNodes);
}
this._insertChildren();
-this.fire("dom-change");
+this.fire('dom-change');
},
-detached: function() {
+detached: function () {
this._removeChildren();
}
});

Powered by Google App Engine
This is Rietveld 408576698