1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

update components

This commit is contained in:
Luke Pulverenti 2016-02-22 23:20:13 -05:00
parent 47a5078596
commit ecbff1ca26
12 changed files with 280 additions and 144 deletions

View file

@ -15,12 +15,12 @@
}, },
"devDependencies": {}, "devDependencies": {},
"ignore": [], "ignore": [],
"version": "1.0.94", "version": "1.0.95",
"_release": "1.0.94", "_release": "1.0.95",
"_resolution": { "_resolution": {
"type": "version", "type": "version",
"tag": "1.0.94", "tag": "1.0.95",
"commit": "5a8fd76f8b8d8096f9aca548127e8d0c2bfe81f9" "commit": "42219487ac4733e83807f9995433ec8485ad1c65"
}, },
"_source": "git://github.com/MediaBrowser/emby-webcomponents.git", "_source": "git://github.com/MediaBrowser/emby-webcomponents.git",
"_target": "~1.0.0", "_target": "~1.0.0",

View file

@ -1,5 +1,10 @@
define([], function () { define([], function () {
function replaceAll(str, find, replace) {
return str.split(find).join(replace);
}
return function (options) { return function (options) {
if (typeof options === 'string') { if (typeof options === 'string') {
@ -9,7 +14,8 @@ define([], function () {
}; };
} }
var result = confirm(options.text); var text = replaceAll(options.text || '', '<br/>', '\n');
var result = confirm(text);
if (result) { if (result) {
return Promise.resolve(); return Promise.resolve();

View file

@ -1,5 +1,10 @@
define([], function () { define([], function () {
function replaceAll(str, find, replace) {
return str.split(find).join(replace);
}
return function (options) { return function (options) {
if (typeof options === 'string') { if (typeof options === 'string') {
@ -9,7 +14,9 @@ define([], function () {
}; };
} }
var result = prompt(options.label || '', options.text || ''); var label = replaceAll(options.label || '', '<br/>', '\n');
var result = prompt(label, options.text || '');
if (result) { if (result) {
return Promise.resolve(result); return Promise.resolve(result);

View file

@ -36,7 +36,7 @@
"tag": "v1.2.4", "tag": "v1.2.4",
"commit": "1ee4e2e11a9e5118320987d93fc2c03ae9a489f4" "commit": "1ee4e2e11a9e5118320987d93fc2c03ae9a489f4"
}, },
"_source": "git://github.com/polymerelements/iron-selector.git", "_source": "git://github.com/PolymerElements/iron-selector.git",
"_target": "^1.0.0", "_target": "^1.0.0",
"_originalSource": "polymerelements/iron-selector" "_originalSource": "PolymerElements/iron-selector"
} }

View file

@ -1,6 +1,6 @@
{ {
"name": "paper-input", "name": "paper-input",
"version": "1.1.6", "version": "1.1.7",
"description": "Material design text fields", "description": "Material design text fields",
"authors": [ "authors": [
"The Polymer Authors" "The Polymer Authors"
@ -47,11 +47,11 @@
"web-component-tester": "^4.0.0", "web-component-tester": "^4.0.0",
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0" "webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
}, },
"_release": "1.1.6", "_release": "1.1.7",
"_resolution": { "_resolution": {
"type": "version", "type": "version",
"tag": "v1.1.6", "tag": "v1.1.7",
"commit": "d918956322b733ee7673aec6e1ce9939aadb4c63" "commit": "209012f7e45990bc0ec1d863b0b9ce515266827e"
}, },
"_source": "git://github.com/polymerelements/paper-input.git", "_source": "git://github.com/polymerelements/paper-input.git",
"_target": "^1.0.9", "_target": "^1.0.9",

View file

@ -1,6 +1,6 @@
{ {
"name": "paper-input", "name": "paper-input",
"version": "1.1.6", "version": "1.1.7",
"description": "Material design text fields", "description": "Material design text fields",
"authors": [ "authors": [
"The Polymer Authors" "The Polymer Authors"

View file

@ -9,6 +9,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
--> -->
<link rel="import" href="../polymer/polymer.html"> <link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../paper-styles/default-theme.html">
<link rel="import" href="../paper-styles/typography.html"> <link rel="import" href="../paper-styles/typography.html">
<link rel="import" href="paper-input-addon-behavior.html"> <link rel="import" href="paper-input-addon-behavior.html">

View file

@ -1,6 +1,6 @@
{ {
"name": "polymer", "name": "polymer",
"version": "1.2.4", "version": "1.3.0",
"main": [ "main": [
"polymer.html", "polymer.html",
"polymer-mini.html", "polymer-mini.html",
@ -27,11 +27,11 @@
}, },
"private": true, "private": true,
"homepage": "https://github.com/Polymer/polymer", "homepage": "https://github.com/Polymer/polymer",
"_release": "1.2.4", "_release": "1.3.0",
"_resolution": { "_resolution": {
"type": "version", "type": "version",
"tag": "v1.2.4", "tag": "v1.3.0",
"commit": "284332a905ddd60eab11901a82ac037976175cf8" "commit": "77504bc2092eed3ad631eff04b186b22e3affb6e"
}, },
"_source": "git://github.com/Polymer/polymer.git", "_source": "git://github.com/Polymer/polymer.git",
"_target": "^1.0.0", "_target": "^1.0.0",

View file

@ -1,6 +1,6 @@
{ {
"name": "polymer", "name": "polymer",
"version": "1.2.4", "version": "1.3.0",
"main": [ "main": [
"polymer.html", "polymer.html",
"polymer-mini.html", "polymer-mini.html",

View file

@ -39,6 +39,7 @@ var useShadow = wantShadow && hasShadow;
var hasNativeImports = Boolean('import' in document.createElement('link')); var hasNativeImports = Boolean('import' in document.createElement('link'));
var useNativeImports = hasNativeImports; var useNativeImports = hasNativeImports;
var useNativeCustomElements = !window.CustomElements || window.CustomElements.useNative; var useNativeCustomElements = !window.CustomElements || window.CustomElements.useNative;
var usePolyfillProto = !useNativeCustomElements && !Object.__proto__;
return { return {
wantShadow: wantShadow, wantShadow: wantShadow,
hasShadow: hasShadow, hasShadow: hasShadow,
@ -46,7 +47,8 @@ nativeShadow: nativeShadow,
useShadow: useShadow, useShadow: useShadow,
useNativeShadow: useShadow && nativeShadow, useNativeShadow: useShadow && nativeShadow,
useNativeImports: useNativeImports, useNativeImports: useNativeImports,
useNativeCustomElements: useNativeCustomElements useNativeCustomElements: useNativeCustomElements,
usePolyfillProto: usePolyfillProto
}; };
}() }()
}; };
@ -78,7 +80,6 @@ prototype = Polymer.Base.chainObject(prototype, base);
prototype.registerCallback(); prototype.registerCallback();
return prototype.constructor; return prototype.constructor;
}; };
window.Polymer = Polymer;
if (userPolymer) { if (userPolymer) {
for (var i in userPolymer) { for (var i in userPolymer) {
Polymer[i] = userPolymer[i]; Polymer[i] = userPolymer[i];
@ -164,7 +165,6 @@ for (var i = 0, h; i < callbacks.length; i++) {
h = callbacks[i]; h = callbacks[i];
h[1].apply(h[0], h[2] || Polymer.nar); h[1].apply(h[0], h[2] || Polymer.nar);
} }
;
} }
}; };
if (window.HTMLImports) { if (window.HTMLImports) {
@ -287,7 +287,7 @@ createdCallback: function () {
this.register(); this.register();
}, },
register: function (id) { register: function (id) {
var id = id || this.id || this.getAttribute('name') || this.getAttribute('is'); id = id || this.id || this.getAttribute('name') || this.getAttribute('is');
if (id) { if (id) {
this.id = id; this.id = id;
modules[id] = this; modules[id] = this;
@ -347,11 +347,16 @@ this.behaviors = this._desugarSomeBehaviors(this.behaviors);
} }
}, },
_desugarSomeBehaviors: function (behaviors) { _desugarSomeBehaviors: function (behaviors) {
var behaviorSet = [];
behaviors = this._flattenBehaviorsList(behaviors); behaviors = this._flattenBehaviorsList(behaviors);
for (var i = behaviors.length - 1; i >= 0; i--) { for (var i = behaviors.length - 1; i >= 0; i--) {
this._mixinBehavior(behaviors[i]); var b = behaviors[i];
if (behaviorSet.indexOf(b) === -1) {
this._mixinBehavior(b);
behaviorSet.unshift(b);
} }
return behaviors; }
return behaviorSet;
}, },
_flattenBehaviorsList: function (behaviors) { _flattenBehaviorsList: function (behaviors) {
var flat = []; var flat = [];
@ -473,7 +478,6 @@ if (info) {
return info; return info;
} }
} }
;
} }
return info || Polymer.nob; return info || Polymer.nob;
}, },
@ -489,7 +493,7 @@ return p;
}, },
_prepPropertyInfo: function () { _prepPropertyInfo: function () {
this._propertyInfo = {}; this._propertyInfo = {};
for (var i = 0, p; i < this.behaviors.length; i++) { for (var i = 0; i < this.behaviors.length; i++) {
this._addPropertyInfo(this._propertyInfo, this.behaviors[i].properties); this._addPropertyInfo(this._propertyInfo, this.behaviors[i].properties);
} }
this._addPropertyInfo(this._propertyInfo, this.properties); this._addPropertyInfo(this._propertyInfo, this.properties);
@ -524,26 +528,17 @@ t.readOnly = s.readOnly;
}); });
Polymer.CaseMap = { Polymer.CaseMap = {
_caseMap: {}, _caseMap: {},
_rx: {
dashToCamel: /-[a-z]/g,
camelToDash: /([A-Z])/g
},
dashToCamelCase: function (dash) { dashToCamelCase: function (dash) {
var mapped = Polymer.CaseMap._caseMap[dash]; return this._caseMap[dash] || (this._caseMap[dash] = dash.indexOf('-') < 0 ? dash : dash.replace(this._rx.dashToCamel, function (m) {
if (mapped) {
return mapped;
}
if (dash.indexOf('-') < 0) {
return Polymer.CaseMap._caseMap[dash] = dash;
}
return Polymer.CaseMap._caseMap[dash] = dash.replace(/-([a-z])/g, function (m) {
return m[1].toUpperCase(); return m[1].toUpperCase();
}); }));
}, },
camelToDashCase: function (camel) { camelToDashCase: function (camel) {
var mapped = Polymer.CaseMap._caseMap[camel]; return this._caseMap[camel] || (this._caseMap[camel] = camel.replace(this._rx.camelToDash, '-$1').toLowerCase());
if (mapped) {
return mapped;
}
return Polymer.CaseMap._caseMap[camel] = camel.replace(/([a-z][A-Z])/g, function (g) {
return g[0] + '-' + g[1].toLowerCase();
});
} }
}; };
Polymer.Base._addFeature({ Polymer.Base._addFeature({
@ -583,7 +578,7 @@ this._setAttributeToProperty(model, info.attribute, i, info);
}, },
_setAttributeToProperty: function (model, attribute, property, info) { _setAttributeToProperty: function (model, attribute, property, info) {
if (!this._serializing) { if (!this._serializing) {
var property = property || Polymer.CaseMap.dashToCamelCase(attribute); property = property || Polymer.CaseMap.dashToCamelCase(attribute);
info = info || this._propertyInfo && this._propertyInfo[property]; info = info || this._propertyInfo && this._propertyInfo[property];
if (info && !info.readOnly) { if (info && !info.readOnly) {
var v = this.getAttribute(attribute); var v = this.getAttribute(attribute);
@ -613,7 +608,7 @@ case Number:
value = Number(value); value = Number(value);
break; break;
case Boolean: case Boolean:
value = value !== null; value = value != null;
break; break;
case Object: case Object:
try { try {
@ -644,7 +639,7 @@ case 'boolean':
return value ? '' : undefined; return value ? '' : undefined;
case 'object': case 'object':
if (value instanceof Date) { if (value instanceof Date) {
return value; return value.toString();
} else if (value) { } else if (value) {
try { try {
return JSON.stringify(value); return JSON.stringify(value);
@ -657,7 +652,7 @@ return value != null ? value : undefined;
} }
} }
}); });
Polymer.version = '1.2.4'; Polymer.version = '1.3.0';
Polymer.Base._addFeature({ Polymer.Base._addFeature({
_registerFeatures: function () { _registerFeatures: function () {
this._prepIs(); this._prepIs();

View file

@ -134,8 +134,8 @@ distances[i][0] = i;
} }
for (var j = 0; j < columnCount; j++) for (var j = 0; j < columnCount; j++)
distances[0][j] = j; distances[0][j] = j;
for (var i = 1; i < rowCount; i++) { for (i = 1; i < rowCount; i++) {
for (var j = 1; j < columnCount; j++) { for (j = 1; j < columnCount; j++) {
if (this.equals(current[currentStart + j - 1], old[oldStart + i - 1])) if (this.equals(current[currentStart + j - 1], old[oldStart + i - 1]))
distances[i][j] = distances[i - 1][j - 1]; distances[i][j] = distances[i - 1][j - 1];
else { else {
@ -215,7 +215,7 @@ return [splice];
} else if (oldStart == oldEnd) } else if (oldStart == oldEnd)
return [newSplice(currentStart, [], currentEnd - currentStart)]; return [newSplice(currentStart, [], currentEnd - currentStart)];
var ops = this.spliceOperationsFromEditDistances(this.calcEditDistances(current, currentStart, currentEnd, old, oldStart, oldEnd)); var ops = this.spliceOperationsFromEditDistances(this.calcEditDistances(current, currentStart, currentEnd, old, oldStart, oldEnd));
var splice = undefined; splice = undefined;
var splices = []; var splices = [];
var index = currentStart; var index = currentStart;
var oldIndex = oldStart; var oldIndex = oldStart;
@ -381,7 +381,7 @@ return { getInnerHTML: getInnerHTML };
var nativeInsertBefore = Element.prototype.insertBefore; var nativeInsertBefore = Element.prototype.insertBefore;
var nativeAppendChild = Element.prototype.appendChild; var nativeAppendChild = Element.prototype.appendChild;
var nativeRemoveChild = Element.prototype.removeChild; var nativeRemoveChild = Element.prototype.removeChild;
var TreeApi = Polymer.TreeApi = { Polymer.TreeApi = {
arrayCopyChildNodes: function (parent) { arrayCopyChildNodes: function (parent) {
var copy = [], i = 0; var copy = [], i = 0;
for (var n = parent.firstChild; n; n = n.nextSibling) { for (var n = parent.firstChild; n; n = n.nextSibling) {
@ -1438,7 +1438,6 @@ return this.node.classList.contains.apply(this.node.classList, arguments);
'use strict'; 'use strict';
var DomApi = Polymer.DomApi.ctor; var DomApi = Polymer.DomApi.ctor;
var Settings = Polymer.Settings; var Settings = Polymer.Settings;
var hasDomApi = Polymer.DomApi.hasDomApi;
DomApi.EffectiveNodesObserver = function (domApi) { DomApi.EffectiveNodesObserver = function (domApi) {
this.domApi = domApi; this.domApi = domApi;
this.node = this.domApi.node; this.node = this.domApi.node;
@ -1491,7 +1490,7 @@ if (this._hasListeners()) {
this._scheduleNotify(); this._scheduleNotify();
} }
}, },
_notify: function (mxns) { _notify: function () {
this._beforeCallListeners(); this._beforeCallListeners();
this._callListeners(); this._callListeners();
}, },
@ -1562,8 +1561,8 @@ for (var j = 0, n; j < s.removed.length && (n = s.removed[j]); j++) {
info.removedNodes.push(n); info.removedNodes.push(n);
} }
} }
for (var i = 0, s; i < splices.length && (s = splices[i]); i++) { for (i = 0, s; i < splices.length && (s = splices[i]); i++) {
for (var j = s.index; j < s.index + s.addedCount; j++) { for (j = s.index; j < s.index + s.addedCount; j++) {
info.addedNodes.push(newNodes[j]); info.addedNodes.push(newNodes[j]);
} }
} }
@ -1581,7 +1580,6 @@ enableShadowAttributeTracking: function () {
if (Settings.useShadow) { if (Settings.useShadow) {
var baseSetup = DomApi.EffectiveNodesObserver.prototype._setup; var baseSetup = DomApi.EffectiveNodesObserver.prototype._setup;
var baseCleanup = DomApi.EffectiveNodesObserver.prototype._cleanup; var baseCleanup = DomApi.EffectiveNodesObserver.prototype._cleanup;
var beforeCallListeners = DomApi.EffectiveNodesObserver.prototype._beforeCallListeners;
Polymer.Base.extend(DomApi.EffectiveNodesObserver.prototype, { Polymer.Base.extend(DomApi.EffectiveNodesObserver.prototype, {
_setup: function () { _setup: function () {
if (!this._observer) { if (!this._observer) {
@ -1896,7 +1894,7 @@ d -= s.addedCount;
} }
for (var i = 0, s, next; i < splices.length && (s = splices[i]); i++) { for (var i = 0, s, next; i < splices.length && (s = splices[i]); i++) {
next = composed[s.index]; next = composed[s.index];
for (var j = s.index, n; j < s.index + s.addedCount; j++) { for (j = s.index, n; j < s.index + s.addedCount; j++) {
n = children[j]; n = children[j];
TreeApi.Composed.insertBefore(container, n, next); TreeApi.Composed.insertBefore(container, n, next);
composed.splice(j, 0, n); composed.splice(j, 0, n);

View file

@ -22,7 +22,7 @@ _parseNodeAnnotations: function (node, list, stripWhiteSpace) {
return node.nodeType === Node.TEXT_NODE ? this._parseTextNodeAnnotation(node, list) : this._parseElementAnnotations(node, list, stripWhiteSpace); return node.nodeType === Node.TEXT_NODE ? this._parseTextNodeAnnotation(node, list) : this._parseElementAnnotations(node, list, stripWhiteSpace);
}, },
_bindingRegex: function () { _bindingRegex: function () {
var IDENT = '(?:' + '[a-zA-Z_$][\\w.:$-*]*' + ')'; var IDENT = '(?:' + '[a-zA-Z_$][\\w.:$\\-*]*' + ')';
var NUMBER = '(?:' + '[-+]?[0-9]*\\.?[0-9]+(?:[eE][-+]?[0-9]+)?' + ')'; var NUMBER = '(?:' + '[-+]?[0-9]*\\.?[0-9]+(?:[eE][-+]?[0-9]+)?' + ')';
var SQUOTE_STRING = '(?:' + '\'(?:[^\'\\\\]|\\\\.)*\'' + ')'; var SQUOTE_STRING = '(?:' + '\'(?:[^\'\\\\]|\\\\.)*\'' + ')';
var DQUOTE_STRING = '(?:' + '"(?:[^"\\\\]|\\\\.)*"' + ')'; var DQUOTE_STRING = '(?:' + '"(?:[^"\\\\]|\\\\.)*"' + ')';
@ -201,12 +201,14 @@ if (node.localName === 'input' && origName === 'value') {
node.setAttribute(origName, ''); node.setAttribute(origName, '');
} }
node.removeAttribute(origName); node.removeAttribute(origName);
var propertyName = Polymer.CaseMap.dashToCamelCase(name);
if (kind === 'property') { if (kind === 'property') {
name = Polymer.CaseMap.dashToCamelCase(name); name = propertyName;
} }
return { return {
kind: kind, kind: kind,
name: name, name: name,
propertyName: propertyName,
parts: parts, parts: parts,
literal: literal, literal: literal,
isCompound: parts.length !== 1 isCompound: parts.length !== 1
@ -311,8 +313,10 @@ var b = note.bindings[j];
for (var k = 0; k < b.parts.length; k++) { for (var k = 0; k < b.parts.length; k++) {
var p = b.parts[k]; var p = b.parts[k];
if (!p.literal) { if (!p.literal) {
p.signature = this._parseMethod(p.value); var signature = this._parseMethod(p.value);
if (!p.signature) { if (signature) {
p.signature = signature;
} else {
p.model = this._modelForPath(p.value); p.model = this._modelForPath(p.value);
} }
} }
@ -376,7 +380,7 @@ this._marshalAnnotatedNodes();
this._marshalAnnotatedListeners(); this._marshalAnnotatedListeners();
} }
}, },
_configureAnnotationReferences: function (config) { _configureAnnotationReferences: function () {
var notes = this._notes; var notes = this._notes;
var nodes = this._nodes; var nodes = this._nodes;
for (var i = 0; i < notes.length; i++) { for (var i = 0; i < notes.length; i++) {
@ -705,7 +709,7 @@ if (type === 'touchstart' || type === 'touchmove') {
Gestures.handleTouchAction(ev); Gestures.handleTouchAction(ev);
} }
} }
if (type === 'touchend') { if (type === 'touchend' && !ev.__polymerSimulatedTouch) {
POINTERSTATE.mouse.target = Polymer.dom(ev).rootTarget; POINTERSTATE.mouse.target = Polymer.dom(ev).rootTarget;
ignoreMouse(true); ignoreMouse(true);
} }
@ -719,14 +723,12 @@ var recognizers = Gestures.recognizers;
for (var i = 0, r; i < recognizers.length; i++) { for (var i = 0, r; i < recognizers.length; i++) {
r = recognizers[i]; r = recognizers[i];
if (gs[r.name] && !handled[r.name]) { if (gs[r.name] && !handled[r.name]) {
if (r.flow && r.flow.start.indexOf(ev.type) > -1) { if (r.flow && r.flow.start.indexOf(ev.type) > -1 && r.reset) {
if (r.reset) {
r.reset(); r.reset();
} }
} }
} }
} for (i = 0, r; i < recognizers.length; i++) {
for (var i = 0, r; i < recognizers.length; i++) {
r = recognizers[i]; r = recognizers[i];
if (gs[r.name] && !handled[r.name]) { if (gs[r.name] && !handled[r.name]) {
handled[r.name] = true; handled[r.name] = true;
@ -991,6 +993,9 @@ var movefn = function movefn(e) {
var x = e.clientX, y = e.clientY; var x = e.clientX, y = e.clientY;
if (self.hasMovedEnough(x, y)) { 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';
if (self.info.state === 'start') {
Gestures.prevent('tap');
}
self.info.addMove({ self.info.addMove({
x: x, x: x,
y: y y: y
@ -1005,7 +1010,6 @@ self.info.started = true;
}; };
var upfn = function upfn(e) { var upfn = function upfn(e) {
if (self.info.started) { if (self.info.started) {
Gestures.prevent('tap');
movefn(e); movefn(e);
} }
untrackDocument(self.info); untrackDocument(self.info);
@ -1024,6 +1028,9 @@ var t = Gestures.findOriginalTarget(e);
var ct = e.changedTouches[0]; var ct = e.changedTouches[0];
var x = ct.clientX, y = ct.clientY; var x = ct.clientX, y = ct.clientY;
if (this.hasMovedEnough(x, y)) { if (this.hasMovedEnough(x, y)) {
if (this.info.state === 'start') {
Gestures.prevent('tap');
}
this.info.addMove({ this.info.addMove({
x: x, x: x,
y: y y: y
@ -1037,7 +1044,6 @@ touchend: function (e) {
var t = Gestures.findOriginalTarget(e); var t = Gestures.findOriginalTarget(e);
var ct = e.changedTouches[0]; var ct = e.changedTouches[0];
if (this.info.started) { if (this.info.started) {
Gestures.prevent('tap');
this.info.state = 'end'; this.info.state = 'end';
this.info.addMove({ this.info.addMove({
x: ct.clientX, x: ct.clientX,
@ -1246,7 +1252,7 @@ return n.nodeType === Node.ELEMENT_NODE;
fire: function (type, detail, options) { fire: function (type, detail, options) {
options = options || Polymer.nob; options = options || Polymer.nob;
var node = options.node || this; var node = options.node || this;
var detail = detail === null || detail === undefined ? {} : detail; detail = detail === null || detail === undefined ? {} : detail;
var bubbles = options.bubbles === undefined ? true : options.bubbles; var bubbles = options.bubbles === undefined ? true : options.bubbles;
var cancelable = Boolean(options.cancelable); var cancelable = Boolean(options.cancelable);
var useCache = options._useCache; var useCache = options._useCache;
@ -1430,7 +1436,7 @@ _sortPropertyEffects: function () {
var EFFECT_ORDER = { var EFFECT_ORDER = {
'compute': 0, 'compute': 0,
'annotation': 1, 'annotation': 1,
'computedAnnotation': 2, 'annotatedComputation': 2,
'reflect': 3, 'reflect': 3,
'notify': 4, 'notify': 4,
'observer': 5, 'observer': 5,
@ -1463,11 +1469,11 @@ Object.defineProperty(model, property, defun);
upper: function (name) { upper: function (name) {
return name[0].toUpperCase() + name.substring(1); return name[0].toUpperCase() + name.substring(1);
}, },
_addAnnotatedListener: function (model, index, property, path, event) { _addAnnotatedListener: function (model, index, property, path, event, negated) {
if (!model._bindListeners) { if (!model._bindListeners) {
model._bindListeners = []; model._bindListeners = [];
} }
var fn = this._notedListenerFactory(property, path, this._isStructured(path)); var fn = this._notedListenerFactory(property, path, this._isStructured(path), negated);
var eventName = event || Polymer.CaseMap.camelToDashCase(property) + '-changed'; var eventName = event || Polymer.CaseMap.camelToDashCase(property) + '-changed';
model._bindListeners.push({ model._bindListeners.push({
index: index, index: index,
@ -1483,12 +1489,15 @@ return path.indexOf('.') > 0;
_isEventBogus: function (e, target) { _isEventBogus: function (e, target) {
return e.path && e.path[0] !== target; return e.path && e.path[0] !== target;
}, },
_notedListenerFactory: function (property, path, isStructured) { _notedListenerFactory: function (property, path, isStructured, negated) {
return function (target, value, targetPath) { return function (target, value, targetPath) {
if (targetPath) { if (targetPath) {
this._notifyPath(this._fixPath(path, property, targetPath), value); this._notifyPath(this._fixPath(path, property, targetPath), value);
} else { } else {
value = target[property]; value = target[property];
if (negated) {
value = !value;
}
if (!isStructured) { if (!isStructured) {
this[path] = value; this[path] = value;
} else { } else {
@ -1508,7 +1517,6 @@ for (var i = 0, l = b$.length, info; i < l && (info = b$[i]); i++) {
var node = inst._nodes[info.index]; var node = inst._nodes[info.index];
this._addNotifyListener(node, inst, info.event, info.changedFn); this._addNotifyListener(node, inst, info.event, info.changedFn);
} }
;
}, },
_addNotifyListener: function (element, context, event, changedFn) { _addNotifyListener: function (element, context, event, changedFn) {
element.addEventListener(event, function (e) { element.addEventListener(event, function (e) {
@ -1518,7 +1526,7 @@ return context._notifyListener(changedFn, e);
}; };
Polymer.Base.extend(Polymer.Bind, { Polymer.Base.extend(Polymer.Bind, {
_shouldAddListener: function (effect) { _shouldAddListener: function (effect) {
return effect.name && effect.kind != 'attribute' && effect.kind != 'text' && !effect.isCompound && effect.parts[0].mode === '{' && !effect.parts[0].negate; return effect.name && effect.kind != 'attribute' && effect.kind != 'text' && !effect.isCompound && effect.parts[0].mode === '{';
}, },
_annotationEffect: function (source, value, effect) { _annotationEffect: function (source, value, effect) {
if (source != effect.value) { if (source != effect.value) {
@ -1556,20 +1564,23 @@ var args = Polymer.Bind._marshalArgs(this.__data__, effect, source, value);
if (args) { if (args) {
fn.apply(this, args); fn.apply(this, args);
} }
} else if (effect.dynamicFn) {
} else { } 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]; var fn = this[effect.method];
if (fn) { if (fn) {
this.__setProperty(effect.name, fn.apply(this, args)); var args = Polymer.Bind._marshalArgs(this.__data__, effect, source, value);
if (args) {
var computedvalue = fn.apply(this, args);
this.__setProperty(effect.name, computedvalue);
}
} else if (effect.dynamicFn) {
} else { } 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 computedHost = this._rootDataHost || this;
@ -1583,6 +1594,7 @@ computedvalue = !computedvalue;
} }
this._applyEffectValue(effect, computedvalue); this._applyEffectValue(effect, computedvalue);
} }
} else if (effect.dynamicFn) {
} else { } else {
computedHost._warn(computedHost._logf('_annotatedComputationEffect', 'compute method `' + effect.method + '` not defined')); computedHost._warn(computedHost._logf('_annotatedComputationEffect', 'compute method `' + effect.method + '` not defined'));
} }
@ -1590,6 +1602,7 @@ computedHost._warn(computedHost._logf('_annotatedComputationEffect', 'compute me
_marshalArgs: function (model, effect, path, value) { _marshalArgs: function (model, effect, path, value) {
var values = []; var values = [];
var args = effect.args; var args = effect.args;
var bailoutEarly = args.length > 1 || effect.dynamicFn;
for (var i = 0, l = args.length; i < l; i++) { for (var i = 0, l = args.length; i < l; i++) {
var arg = args[i]; var arg = args[i];
var name = arg.name; var name = arg.name;
@ -1601,7 +1614,7 @@ v = Polymer.Base._get(name, model);
} else { } else {
v = model[name]; v = model[name];
} }
if (args.length > 1 && v === undefined) { if (bailoutEarly && v === undefined) {
return; return;
} }
if (arg.wildcard) { if (arg.wildcard) {
@ -1656,12 +1669,23 @@ Polymer.Bind.ensurePropertyEffects(this, p);
}, },
_addComputedEffect: function (name, expression) { _addComputedEffect: function (name, expression) {
var sig = this._parseMethod(expression); var sig = this._parseMethod(expression);
var dynamicFn = sig.dynamicFn;
for (var i = 0, arg; i < sig.args.length && (arg = sig.args[i]); i++) { for (var i = 0, arg; i < sig.args.length && (arg = sig.args[i]); i++) {
this._addPropertyEffect(arg.model, 'compute', { this._addPropertyEffect(arg.model, 'compute', {
method: sig.method, method: sig.method,
args: sig.args, args: sig.args,
trigger: arg, trigger: arg,
name: name name: name,
dynamicFn: dynamicFn
});
}
if (dynamicFn) {
this._addPropertyEffect(sig.method, 'compute', {
method: sig.method,
args: sig.args,
trigger: null,
name: name,
dynamicFn: dynamicFn
}); });
} }
}, },
@ -1683,11 +1707,21 @@ var sig = this._parseMethod(observer);
if (!sig) { if (!sig) {
throw new Error('Malformed observer expression \'' + observer + '\''); throw new Error('Malformed observer expression \'' + observer + '\'');
} }
var dynamicFn = sig.dynamicFn;
for (var i = 0, arg; i < sig.args.length && (arg = sig.args[i]); i++) { for (var i = 0, arg; i < sig.args.length && (arg = sig.args[i]); i++) {
this._addPropertyEffect(arg.model, 'complexObserver', { this._addPropertyEffect(arg.model, 'complexObserver', {
method: sig.method, method: sig.method,
args: sig.args, args: sig.args,
trigger: arg trigger: arg,
dynamicFn: dynamicFn
});
}
if (dynamicFn) {
this._addPropertyEffect(sig.method, 'complexObserver', {
method: sig.method,
args: sig.args,
trigger: null,
dynamicFn: dynamicFn
}); });
} }
}, },
@ -1701,7 +1735,7 @@ this._addAnnotationEffect(binding, i);
}, },
_addAnnotationEffect: function (note, index) { _addAnnotationEffect: function (note, index) {
if (Polymer.Bind._shouldAddListener(note)) { if (Polymer.Bind._shouldAddListener(note)) {
Polymer.Bind._addAnnotatedListener(this, index, note.name, note.parts[0].value, note.parts[0].event); Polymer.Bind._addAnnotatedListener(this, index, note.name, note.parts[0].value, note.parts[0].event, note.parts[0].negate);
} }
for (var i = 0; i < note.parts.length; i++) { for (var i = 0; i < note.parts.length; i++) {
var part = note.parts[i]; var part = note.parts[i];
@ -1712,6 +1746,7 @@ this._addPropertyEffect(part.model, 'annotation', {
kind: note.kind, kind: note.kind,
index: index, index: index,
name: note.name, name: note.name,
propertyName: note.propertyName,
value: part.value, value: part.value,
isCompound: note.isCompound, isCompound: note.isCompound,
compoundIndex: part.compoundIndex, compoundIndex: part.compoundIndex,
@ -1732,6 +1767,9 @@ if (!arg.literal) {
this.__addAnnotatedComputationEffect(arg.model, index, note, part, arg); this.__addAnnotatedComputationEffect(arg.model, index, note, part, arg);
} }
} }
if (sig.dynamicFn) {
this.__addAnnotatedComputationEffect(sig.method, index, note, part, null);
}
} }
}, },
__addAnnotatedComputationEffect: function (property, index, note, part, trigger) { __addAnnotatedComputationEffect: function (property, index, note, part, trigger) {
@ -1744,16 +1782,21 @@ name: note.name,
negate: part.negate, negate: part.negate,
method: part.signature.method, method: part.signature.method,
args: part.signature.args, args: part.signature.args,
trigger: trigger trigger: trigger,
dynamicFn: part.signature.dynamicFn
}); });
}, },
_parseMethod: function (expression) { _parseMethod: function (expression) {
var m = expression.match(/([^\s]+?)\((.*)\)/); var m = expression.match(/([^\s]+?)\(([\s\S]*)\)/);
if (m) { if (m) {
var sig = { var sig = {
method: m[1], method: m[1],
static: true static: true
}; };
if (this.getPropertyInfo(sig.method) !== Polymer.nob) {
sig.static = false;
sig.dynamicFn = true;
}
if (m[2].trim()) { 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); return this._parseArgs(args, sig);
@ -1841,6 +1884,8 @@ this._effectEffects('__static__', null, this._propertyEffects.__static__);
} }
} }
}); });
(function () {
var usePolyfillProto = Polymer.Settings.usePolyfillProto;
Polymer.Base._addFeature({ Polymer.Base._addFeature({
_setupConfigure: function (initialConfig) { _setupConfigure: function (initialConfig) {
this._config = {}; this._config = {};
@ -1887,7 +1932,10 @@ this._distributeConfig(this._config);
_configureProperties: function (properties, config) { _configureProperties: function (properties, config) {
for (var i in properties) { for (var i in properties) {
var c = properties[i]; var c = properties[i];
if (c.value !== undefined) { if (!usePolyfillProto && this.hasOwnProperty(i) && this._propertyEffects && this._propertyEffects[i]) {
config[i] = this[i];
delete this[i];
} else if (c.value !== undefined) {
var value = c.value; var value = c.value;
if (typeof value == 'function') { if (typeof value == 'function') {
value = value.call(this, this._config); value = value.call(this, this._config);
@ -1905,9 +1953,15 @@ if (fx) {
for (var i = 0, l = fx.length, x; i < l && (x = fx[i]); i++) { for (var i = 0, l = fx.length, x; i < l && (x = fx[i]); i++) {
if (x.kind === 'annotation' && !x.isCompound) { if (x.kind === 'annotation' && !x.isCompound) {
var node = this._nodes[x.effect.index]; var node = this._nodes[x.effect.index];
if (node._configValue) { var name = x.effect.propertyName;
var isAttr = x.effect.kind == 'attribute';
var hasEffect = node._propertyEffects && node._propertyEffects[name];
if (node._configValue && (hasEffect || !isAttr)) {
var value = p === x.effect.value ? config[p] : this._get(x.effect.value, config); var value = p === x.effect.value ? config[p] : this._get(x.effect.value, config);
node._configValue(x.effect.name, value); if (isAttr) {
value = node.deserialize(this.serialize(value), node._propertyInfo[name].type);
}
node._configValue(name, value);
} }
} }
} }
@ -1957,6 +2011,7 @@ h[0].call(this, h[1], h[2], h[3]);
this._handlers = []; this._handlers = [];
} }
}); });
}());
(function () { (function () {
'use strict'; 'use strict';
Polymer.Base._addFeature({ Polymer.Base._addFeature({
@ -2014,14 +2069,15 @@ array = Array.isArray(prop) ? prop : null;
} }
if (array) { if (array) {
var coll = Polymer.Collection.get(array); var coll = Polymer.Collection.get(array);
var old, key;
if (last[0] == '#') { if (last[0] == '#') {
var key = last; key = last;
var old = coll.getItem(key); old = coll.getItem(key);
last = array.indexOf(old); last = array.indexOf(old);
coll.setItem(key, value); coll.setItem(key, value);
} else if (parseInt(last, 10) == last) { } else if (parseInt(last, 10) == last) {
var old = prop[last]; old = prop[last];
var key = coll.getKey(old); key = coll.getKey(old);
parts[i] = key; parts[i] = key;
coll.setItem(key, value); coll.setItem(key, value);
} }
@ -2202,7 +2258,7 @@ this._notifySplice(array, info.path, array.length, 0, [ret]);
} }
return ret; return ret;
}, },
splice: function (path, start, deleteCount) { splice: function (path, start) {
var info = {}; var info = {};
var array = this._get(path, this, info); var array = this._get(path, this, info);
if (start < 0) { if (start < 0) {
@ -2330,6 +2386,7 @@ if (s.indexOf(this.MEDIA_START) === 0) {
node.type = this.types.MEDIA_RULE; node.type = this.types.MEDIA_RULE;
} else if (s.match(this._rx.keyframesRule)) { } else if (s.match(this._rx.keyframesRule)) {
node.type = this.types.KEYFRAMES_RULE; node.type = this.types.KEYFRAMES_RULE;
node.keyframesName = node.selector.split(this._rx.multipleSpaces).pop();
} }
} else { } else {
if (s.indexOf(this.VAR_START) === 0) { if (s.indexOf(this.VAR_START) === 0) {
@ -2429,14 +2486,14 @@ if (typeof rules === 'string') {
rules = this.parser.parse(rules); rules = this.parser.parse(rules);
} }
if (callback) { if (callback) {
this.forEachStyleRule(rules, callback); this.forEachRule(rules, callback);
} }
return this.parser.stringify(rules, preserveProperties); return this.parser.stringify(rules, preserveProperties);
}, },
forRulesInStyles: function (styles, callback) { forRulesInStyles: function (styles, styleRuleCallback, keyframesRuleCallback) {
if (styles) { if (styles) {
for (var i = 0, l = styles.length, s; i < l && (s = styles[i]); i++) { for (var i = 0, l = styles.length, s; i < l && (s = styles[i]); i++) {
this.forEachStyleRule(this.rulesForStyle(s), callback); this.forEachRule(this.rulesForStyle(s), styleRuleCallback, keyframesRuleCallback);
} }
} }
}, },
@ -2446,20 +2503,25 @@ style.__cssRules = this.parser.parse(style.textContent);
} }
return style.__cssRules; return style.__cssRules;
}, },
forEachStyleRule: function (node, callback) { isKeyframesSelector: function (rule) {
return rule.parent && rule.parent.type === this.ruleTypes.KEYFRAMES_RULE;
},
forEachRule: function (node, styleRuleCallback, keyframesRuleCallback) {
if (!node) { if (!node) {
return; return;
} }
var skipRules = false; var skipRules = false;
if (node.type === this.ruleTypes.STYLE_RULE) { if (node.type === this.ruleTypes.STYLE_RULE) {
callback(node); styleRuleCallback(node);
} else if (node.type === this.ruleTypes.KEYFRAMES_RULE || node.type === this.ruleTypes.MIXIN_RULE) { } else if (keyframesRuleCallback && node.type === this.ruleTypes.KEYFRAMES_RULE) {
keyframesRuleCallback(node);
} else if (node.type === this.ruleTypes.MIXIN_RULE) {
skipRules = true; skipRules = true;
} }
var r$ = node.rules; var r$ = node.rules;
if (r$ && !skipRules) { if (r$ && !skipRules) {
for (var i = 0, l = r$.length, r; i < l && (r = r$[i]); i++) { for (var i = 0, l = r$.length, r; i < l && (r = r$[i]); i++) {
this.forEachStyleRule(r, callback); this.forEachRule(r, styleRuleCallback, keyframesRuleCallback);
} }
} }
}, },
@ -2608,15 +2670,18 @@ 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); var p$ = rule.selector.split(COMPLEX_SELECTOR_SEP);
if (!styleUtil.isKeyframesSelector(rule)) {
for (var i = 0, l = p$.length, p; i < l && (p = p$[i]); i++) { for (var i = 0, l = p$.length, p; i < l && (p = p$[i]); i++) {
p$[i] = transformer.call(this, p, scope, hostScope); p$[i] = transformer.call(this, p, scope, hostScope);
} }
}
rule.selector = rule.transformedSelector = p$.join(COMPLEX_SELECTOR_SEP); rule.selector = rule.transformedSelector = p$.join(COMPLEX_SELECTOR_SEP);
}, },
_transformComplexSelector: function (selector, scope, hostScope) { _transformComplexSelector: function (selector, scope, hostScope) {
var stop = false; var stop = false;
var hostContext = false; var hostContext = false;
var self = this; var self = this;
selector = selector.replace(CONTENT_START, HOST + ' $1');
selector = selector.replace(SIMPLE_SELECTOR_SEP, function (m, c, s) { selector = selector.replace(SIMPLE_SELECTOR_SEP, function (m, c, s) {
if (!stop) { if (!stop) {
var info = self._transformCompoundSelector(s, c, scope, hostScope); var info = self._transformCompoundSelector(s, c, scope, hostScope);
@ -2689,10 +2754,10 @@ SCOPE_NAME: 'style-scope'
var SCOPE_NAME = api.SCOPE_NAME; var SCOPE_NAME = api.SCOPE_NAME;
var SCOPE_DOC_SELECTOR = ':not([' + SCOPE_NAME + '])' + ':not(.' + SCOPE_NAME + ')'; var SCOPE_DOC_SELECTOR = ':not([' + SCOPE_NAME + '])' + ':not(.' + SCOPE_NAME + ')';
var COMPLEX_SELECTOR_SEP = ','; var COMPLEX_SELECTOR_SEP = ',';
var SIMPLE_SELECTOR_SEP = /(^|[\s>+~]+)([^\s>+~]+)/g; var SIMPLE_SELECTOR_SEP = /(^|[\s>+~]+)((?:\[.+?\]|[^\s>+~=\[])+)/g;
var HOST = ':host'; var HOST = ':host';
var ROOT = ':root'; var ROOT = ':root';
var HOST_PAREN = /(\:host)(?:\(((?:\([^)(]*\)|[^)(]*)+?)\))/g; var HOST_PAREN = /(:host)(?:\(((?:\([^)(]*\)|[^)(]*)+?)\))/g;
var HOST_CONTEXT = ':host-context'; var HOST_CONTEXT = ':host-context';
var HOST_CONTEXT_PAREN = /(.*)(?::host-context)(?:\(((?:\([^)(]*\)|[^)(]*)+?)\))(.*)/; var HOST_CONTEXT_PAREN = /(.*)(?::host-context)(?:\(((?:\([^)(]*\)|[^)(]*)+?)\))(.*)/;
var CONTENT = '::content'; var CONTENT = '::content';
@ -2702,6 +2767,7 @@ var CSS_ATTR_PREFIX = '[' + SCOPE_NAME + '~=';
var CSS_ATTR_SUFFIX = ']'; var CSS_ATTR_SUFFIX = ']';
var PSEUDO_PREFIX = ':'; var PSEUDO_PREFIX = ':';
var CLASS = 'class'; var CLASS = 'class';
var CONTENT_START = new RegExp('^(' + CONTENT + ')');
return api; return api;
}(); }();
Polymer.StyleExtends = function () { Polymer.StyleExtends = function () {
@ -2713,8 +2779,8 @@ return Boolean(cssText.match(this.rx.EXTEND));
transform: function (style) { transform: function (style) {
var rules = styleUtil.rulesForStyle(style); var rules = styleUtil.rulesForStyle(style);
var self = this; var self = this;
styleUtil.forEachStyleRule(rules, function (rule) { styleUtil.forEachRule(rules, function (rule) {
var map = self._mapRule(rule); self._mapRuleOntoParent(rule);
if (rule.parent) { if (rule.parent) {
var m; var m;
while (m = self.rx.EXTEND.exec(rule.cssText)) { while (m = self.rx.EXTEND.exec(rule.cssText)) {
@ -2733,7 +2799,7 @@ rule.cssText = '';
} }
}, true); }, true);
}, },
_mapRule: function (rule) { _mapRuleOntoParent: function (rule) {
if (rule.parent) { if (rule.parent) {
var map = rule.parent.map || (rule.parent.map = {}); var map = rule.parent.map || (rule.parent.map = {});
var parts = rule.selector.split(','); var parts = rule.selector.split(',');
@ -2795,7 +2861,9 @@ this._encapsulateStyle = !nativeShadow && Boolean(this._template);
if (this._template) { if (this._template) {
this._styles = this._collectStyles(); this._styles = this._collectStyles();
var cssText = styleTransformer.elementStyles(this); var cssText = styleTransformer.elementStyles(this);
if (cssText) { var needsStatic = this._needsStaticStyles(this._styles);
if (needsStatic || !nativeShadow) {
cssText = needsStatic ? cssText : ' ';
var style = styleUtil.applyCss(cssText, this.is, nativeShadow ? this._template.content : null); var style = styleUtil.applyCss(cssText, this.is, nativeShadow ? this._template.content : null);
if (!nativeShadow) { if (!nativeShadow) {
this._scopeStyle = style; this._scopeStyle = style;
@ -2886,11 +2954,14 @@ var styleUtil = Polymer.StyleUtil;
var styleTransformer = Polymer.StyleTransformer; var styleTransformer = Polymer.StyleTransformer;
return { return {
decorateStyles: function (styles) { decorateStyles: function (styles) {
var self = this, props = {}; var self = this, props = {}, keyframes = [];
styleUtil.forRulesInStyles(styles, function (rule) { styleUtil.forRulesInStyles(styles, function (rule) {
self.decorateRule(rule); self.decorateRule(rule);
self.collectPropertiesInCssText(rule.propertyInfo.cssText, props); self.collectPropertiesInCssText(rule.propertyInfo.cssText, props);
}, function onKeyframesRule(rule) {
keyframes.push(rule);
}); });
styles._keyframes = keyframes;
var names = []; var names = [];
for (var i in props) { for (var i in props) {
names.push(i); names.push(i);
@ -2930,17 +3001,9 @@ return any;
} }
}, },
collectCssText: function (rule) { collectCssText: function (rule) {
var customCssText = '';
var cssText = rule.parsedCssText; var cssText = rule.parsedCssText;
cssText = cssText.replace(this.rx.BRACKETED, '').replace(this.rx.VAR_ASSIGN, ''); cssText = cssText.replace(this.rx.BRACKETED, '').replace(this.rx.VAR_ASSIGN, '');
var parts = cssText.split(';'); return cssText;
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';
}
}
return customCssText;
}, },
collectPropertiesInCssText: function (cssText, props) { collectPropertiesInCssText: function (cssText, props) {
var m; var m;
@ -2982,12 +3045,13 @@ m = p.match(this.rx.MIXIN_MATCH);
if (m) { if (m) {
p = this.valueForProperty(props[m[1]], props); p = this.valueForProperty(props[m[1]], props);
} else { } else {
var pp = p.split(':'); var colon = p.indexOf(':');
if (pp[1]) { if (colon !== -1) {
pp[1] = pp[1].trim(); var pp = p.substring(colon);
pp[1] = this.valueForProperty(pp[1], props) || pp[1]; pp = pp.trim();
pp = this.valueForProperty(pp, props) || pp;
p = p.substring(0, colon) + pp;
} }
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 || '';
} }
@ -3004,6 +3068,34 @@ output = this.valueForProperties(rule.propertyInfo.cssText, props);
} }
rule.cssText = output; rule.cssText = output;
}, },
applyKeyframeTransforms: function (rule, keyframeTransforms) {
var input = rule.cssText;
var output = rule.cssText;
if (rule.hasAnimations == null) {
rule.hasAnimations = this.rx.ANIMATION_MATCH.test(input);
}
if (rule.hasAnimations) {
var transform;
if (rule.keyframeNamesToTransform == null) {
rule.keyframeNamesToTransform = [];
for (var keyframe in keyframeTransforms) {
transform = keyframeTransforms[keyframe];
output = transform(input);
if (input !== output) {
input = output;
rule.keyframeNamesToTransform.push(keyframe);
}
}
} else {
for (var i = 0; i < rule.keyframeNamesToTransform.length; ++i) {
transform = keyframeTransforms[rule.keyframeNamesToTransform[i]];
input = transform(input);
}
output = input;
}
}
rule.cssText = output;
},
propertyDataFromStyles: function (styles, element) { propertyDataFromStyles: function (styles, element) {
var props = {}, self = this; var props = {}, self = this;
var o = [], i = 0; var o = [], i = 0;
@ -3054,20 +3146,44 @@ var self = this;
var hostSelector = styleTransformer._calcHostScope(element.is, element.extends); var hostSelector = styleTransformer._calcHostScope(element.is, element.extends);
var rxHostSelector = element.extends ? '\\' + hostSelector.slice(0, -1) + '\\]' : hostSelector; var rxHostSelector = element.extends ? '\\' + hostSelector.slice(0, -1) + '\\]' : hostSelector;
var hostRx = new RegExp(this.rx.HOST_PREFIX + rxHostSelector + this.rx.HOST_SUFFIX); var hostRx = new RegExp(this.rx.HOST_PREFIX + rxHostSelector + this.rx.HOST_SUFFIX);
var keyframeTransforms = this._elementKeyframeTransforms(element, scopeSelector);
return styleTransformer.elementStyles(element, function (rule) { return styleTransformer.elementStyles(element, function (rule) {
self.applyProperties(rule, properties); self.applyProperties(rule, properties);
if (rule.cssText && !nativeShadow) { if (!nativeShadow && !Polymer.StyleUtil.isKeyframesSelector(rule) && rule.cssText) {
self.applyKeyframeTransforms(rule, keyframeTransforms);
self._scopeSelector(rule, hostRx, hostSelector, element._scopeCssViaAttr, scopeSelector); self._scopeSelector(rule, hostRx, hostSelector, element._scopeCssViaAttr, scopeSelector);
} }
}); });
}, },
_elementKeyframeTransforms: function (element, scopeSelector) {
var keyframesRules = element._styles._keyframes;
var keyframeTransforms = {};
if (!nativeShadow) {
for (var i = 0, keyframesRule = keyframesRules[i]; i < keyframesRules.length; keyframesRule = keyframesRules[++i]) {
this._scopeKeyframes(keyframesRule, scopeSelector);
keyframeTransforms[keyframesRule.keyframesName] = this._keyframesRuleTransformer(keyframesRule);
}
}
return keyframeTransforms;
},
_keyframesRuleTransformer: function (keyframesRule) {
return function (cssText) {
return cssText.replace(keyframesRule.keyframesNameRx, keyframesRule.transformedKeyframesName);
};
},
_scopeKeyframes: function (rule, scopeId) {
rule.keyframesNameRx = new RegExp(rule.keyframesName, 'g');
rule.transformedKeyframesName = rule.keyframesName + '-' + scopeId;
rule.transformedSelector = rule.transformedSelector || rule.selector;
rule.selector = rule.transformedSelector.replace(rule.keyframesName, rule.transformedKeyframesName);
},
_scopeSelector: function (rule, hostRx, hostSelector, viaAttr, scopeId) { _scopeSelector: function (rule, hostRx, hostSelector, viaAttr, scopeId) {
rule.transformedSelector = rule.transformedSelector || rule.selector; rule.transformedSelector = rule.transformedSelector || rule.selector;
var selector = rule.transformedSelector; var selector = rule.transformedSelector;
var scope = viaAttr ? '[' + styleTransformer.SCOPE_NAME + '~=' + scopeId + ']' : '.' + scopeId; var scope = viaAttr ? '[' + styleTransformer.SCOPE_NAME + '~=' + scopeId + ']' : '.' + scopeId;
var parts = selector.split(','); var parts = selector.split(',');
for (var i = 0, l = parts.length, p; i < l && (p = parts[i]); i++) { for (var i = 0, l = parts.length, p; i < l && (p = parts[i]); i++) {
parts[i] = p.match(hostRx) ? p.replace(hostSelector, hostSelector + scope) : scope + ' ' + p; parts[i] = p.match(hostRx) ? p.replace(hostSelector, scope) : scope + ' ' + p;
} }
rule.selector = parts.join(','); rule.selector = parts.join(',');
}, },
@ -3120,8 +3236,9 @@ props[i] = v;
rx: { rx: {
VAR_ASSIGN: /(?:^|[;\s{]\s*)(--[\w-]*?)\s*:\s*(?:([^;{]*)|{([^}]*)})(?:(?=[;\s}])|$)/gi, VAR_ASSIGN: /(?:^|[;\s{]\s*)(--[\w-]*?)\s*:\s*(?:([^;{]*)|{([^}]*)})(?:(?=[;\s}])|$)/gi,
MIXIN_MATCH: /(?:^|\W+)@apply[\s]*\(([^)]*)\)/i, MIXIN_MATCH: /(?:^|\W+)@apply[\s]*\(([^)]*)\)/i,
VAR_MATCH: /(^|\W+)var\([\s]*([^,)]*)[\s]*,?[\s]*((?:[^,)]*)|(?:[^;]*\([^;)]*\)))[\s]*?\)/gi, VAR_MATCH: /(^|\W+)var\([\s]*([^,)]*)[\s]*,?[\s]*((?:[^,()]*)|(?:[^;()]*\([^;)]*\)))[\s]*?\)/gi,
VAR_CAPTURE: /\([\s]*(--[^,\s)]*)(?:,[\s]*(--[^,\s)]*))?(?:\)|,)/gi, VAR_CAPTURE: /\([\s]*(--[^,\s)]*)(?:,[\s]*(--[^,\s)]*))?(?:\)|,)/gi,
ANIMATION_MATCH: /(animation\s*:)|(animation-name\s*:)/,
IS_VAR: /^--/, IS_VAR: /^--/,
BRACKETED: /\{[^}]*\}/g, BRACKETED: /\{[^}]*\}/g,
HOST_PREFIX: '(?:^|[^.#[:])', HOST_PREFIX: '(?:^|[^.#[:])',
@ -3186,7 +3303,6 @@ return this._objectsEqual(target, source) && this._objectsEqual(source, target);
}()); }());
Polymer.StyleDefaults = function () { Polymer.StyleDefaults = function () {
var styleProperties = Polymer.StyleProperties; var styleProperties = Polymer.StyleProperties;
var styleUtil = Polymer.StyleUtil;
var StyleCache = Polymer.StyleCache; var StyleCache = Polymer.StyleCache;
var api = { var api = {
_styles: [], _styles: [],
@ -3231,11 +3347,22 @@ return api;
'use strict'; 'use strict';
var serializeValueToAttribute = Polymer.Base.serializeValueToAttribute; var serializeValueToAttribute = Polymer.Base.serializeValueToAttribute;
var propertyUtils = Polymer.StyleProperties; var propertyUtils = Polymer.StyleProperties;
var styleTransformer = Polymer.StyleTransformer;
var styleUtil = Polymer.StyleUtil; var styleUtil = Polymer.StyleUtil;
var styleTransformer = Polymer.StyleTransformer;
var styleDefaults = Polymer.StyleDefaults; var styleDefaults = Polymer.StyleDefaults;
var nativeShadow = Polymer.Settings.useNativeShadow; var nativeShadow = Polymer.Settings.useNativeShadow;
Polymer.Base._addFeature({ Polymer.Base._addFeature({
_needsStaticStyles: function (styles) {
var needsStatic;
for (var i = 0, l = styles.length, css; i < l; i++) {
css = styleUtil.parser._clean(styles[i].textContent);
needsStatic = needsStatic || Boolean(css);
if (css.match(propertyUtils.rx.MIXIN_MATCH) || css.match(propertyUtils.rx.VAR_MATCH)) {
return false;
}
}
return needsStatic;
},
_prepStyleProperties: function () { _prepStyleProperties: function () {
this._ownStylePropertyNames = this._styles ? propertyUtils.decorateStyles(this._styles) : null; this._ownStylePropertyNames = this._styles ? propertyUtils.decorateStyles(this._styles) : null;
}, },
@ -3349,7 +3476,7 @@ serializeValueToAttribute.call(this, value, attribute, node);
}, },
_scopeElementClass: function (element, selector) { _scopeElementClass: function (element, selector) {
if (!nativeShadow && !this._scopeCssViaAttr) { if (!nativeShadow && !this._scopeCssViaAttr) {
selector += (selector ? ' ' : '') + SCOPE_NAME + ' ' + this.is + (element._scopeSelector ? ' ' + XSCOPE_NAME + ' ' + element._scopeSelector : ''); selector = (selector ? selector + ' ' : '') + SCOPE_NAME + ' ' + this.is + (element._scopeSelector ? ' ' + XSCOPE_NAME + ' ' + element._scopeSelector : '');
} }
return selector; return selector;
}, },
@ -3436,7 +3563,6 @@ this._listenListeners(b.listeners);
} }
}); });
(function () { (function () {
var nativeShadow = Polymer.Settings.useNativeShadow;
var propertyUtils = Polymer.StyleProperties; var propertyUtils = Polymer.StyleProperties;
var styleUtil = Polymer.StyleUtil; var styleUtil = Polymer.StyleUtil;
var cssParse = Polymer.CssParse; var cssParse = Polymer.CssParse;
@ -3478,7 +3604,7 @@ if (this.include) {
e.textContent = styleUtil.cssFromModules(this.include, true) + e.textContent; e.textContent = styleUtil.cssFromModules(this.include, true) + e.textContent;
} }
if (e.textContent) { if (e.textContent) {
styleUtil.forEachStyleRule(styleUtil.rulesForStyle(e), function (rule) { styleUtil.forEachRule(styleUtil.rulesForStyle(e), function (rule) {
styleTransformer.documentRule(rule); styleTransformer.documentRule(rule);
}); });
var self = this; var self = this;
@ -3583,7 +3709,7 @@ this.__setPropertyOrig(property, value, fromAbove, node);
_debounceTemplate: function (fn) { _debounceTemplate: function (fn) {
Polymer.dom.addDebouncer(this.debounce('_debounceTemplate', fn)); Polymer.dom.addDebouncer(this.debounce('_debounceTemplate', fn));
}, },
_flushTemplates: function (debouncerExpired) { _flushTemplates: function () {
Polymer.dom.flush(); Polymer.dom.flush();
}, },
_customPrepEffects: function (archetype) { _customPrepEffects: function (archetype) {
@ -3591,7 +3717,7 @@ var parentProps = archetype._parentProps;
for (var prop in parentProps) { for (var prop in parentProps) {
archetype._addPropertyEffect(prop, 'function', this._createHostPropEffector(prop)); archetype._addPropertyEffect(prop, 'function', this._createHostPropEffector(prop));
} }
for (var prop in this._instanceProps) { for (prop in this._instanceProps) {
archetype._addPropertyEffect(prop, 'function', this._createInstancePropEffector(prop)); archetype._addPropertyEffect(prop, 'function', this._createInstancePropEffector(prop));
} }
}, },
@ -3676,6 +3802,9 @@ this.dataHost._forwardInstanceProp(this, prop, value);
}, },
_extendTemplate: function (template, proto) { _extendTemplate: function (template, proto) {
var n$ = Object.getOwnPropertyNames(proto); var n$ = Object.getOwnPropertyNames(proto);
if (proto._propertySetter) {
template._propertySetter = proto._propertySetter;
}
for (var i = 0, n; i < n$.length && (n = n$[i]); i++) { for (var i = 0, n; i < n$.length && (n = n$[i]); i++) {
var val = template[n]; var val = template[n];
var pd = Object.getOwnPropertyDescriptor(proto, n); var pd = Object.getOwnPropertyDescriptor(proto, n);
@ -3756,9 +3885,11 @@ model = model || {};
if (this._parentProps) { if (this._parentProps) {
var templatized = this._templatized; var templatized = this._templatized;
for (var prop in this._parentProps) { for (var prop in this._parentProps) {
if (model[prop] === undefined) {
model[prop] = templatized[this._parentPropPrefix + prop]; model[prop] = templatized[this._parentPropPrefix + prop];
} }
} }
}
return new this.ctor(model, this); return new this.ctor(model, this);
}, },
modelForElement: function (el) { modelForElement: function (el) {
@ -3889,7 +4020,7 @@ for (var j = 0; j < s.removed.length; j++) {
key = this.getKey(s.removed[j]); key = this.getKey(s.removed[j]);
keyMap[key] = keyMap[key] ? null : -1; keyMap[key] = keyMap[key] ? null : -1;
} }
for (var j = 0; j < s.addedCount; j++) { for (j = 0; j < s.addedCount; j++) {
var item = this.userArray[s.index + j]; var item = this.userArray[s.index + j];
key = this.getKey(item); key = this.getKey(item);
key = key === undefined ? this.add(item) : key; key = key === undefined ? this.add(item) : key;
@ -3899,7 +4030,7 @@ s.addedKeys.push(key);
} }
var removed = []; var removed = [];
var added = []; var added = [];
for (var key in keyMap) { for (key in keyMap) {
if (keyMap[key] < 0) { if (keyMap[key] < 0) {
this.removeKey(key); this.removeKey(key);
removed.push(key); removed.push(key);
@ -4096,7 +4227,6 @@ this._debounceTemplate(this._render);
this._flushTemplates(); this._flushTemplates();
}, },
_render: function () { _render: function () {
var c = this.collection;
if (this._needFullRefresh) { if (this._needFullRefresh) {
this._applyFullRefresh(); this._applyFullRefresh();
this._needFullRefresh = false; this._needFullRefresh = false;
@ -4157,7 +4287,7 @@ keys.sort(function (a, b) {
return self._sortFn(c.getItem(a), c.getItem(b)); return self._sortFn(c.getItem(a), c.getItem(b));
}); });
} }
for (var i = 0; i < keys.length; i++) { for (i = 0; i < keys.length; i++) {
var key = keys[i]; var key = keys[i];
var inst = this._instances[i]; var inst = this._instances[i];
if (inst) { if (inst) {
@ -4180,21 +4310,21 @@ return a - b;
}, },
_applySplicesUserSort: function (splices) { _applySplicesUserSort: function (splices) {
var c = this.collection; var c = this.collection;
var instances = this._instances;
var keyMap = {}; var keyMap = {};
var key;
for (var i = 0, s; i < splices.length && (s = splices[i]); i++) { for (var i = 0, s; i < splices.length && (s = splices[i]); i++) {
for (var j = 0; j < s.removed.length; j++) { for (var j = 0; j < s.removed.length; j++) {
var key = s.removed[j]; key = s.removed[j];
keyMap[key] = keyMap[key] ? null : -1; keyMap[key] = keyMap[key] ? null : -1;
} }
for (var j = 0; j < s.added.length; j++) { for (j = 0; j < s.added.length; j++) {
var key = s.added[j]; key = s.added[j];
keyMap[key] = keyMap[key] ? null : 1; keyMap[key] = keyMap[key] ? null : 1;
} }
} }
var removedIdxs = []; var removedIdxs = [];
var addedKeys = []; var addedKeys = [];
for (var key in keyMap) { for (key in keyMap) {
if (keyMap[key] === -1) { if (keyMap[key] === -1) {
removedIdxs.push(this._keyToInstIdx[key]); removedIdxs.push(this._keyToInstIdx[key]);
} }
@ -4204,7 +4334,7 @@ addedKeys.push(key);
} }
if (removedIdxs.length) { if (removedIdxs.length) {
removedIdxs.sort(this._numericSort); removedIdxs.sort(this._numericSort);
for (var i = removedIdxs.length - 1; i >= 0; i--) { for (i = removedIdxs.length - 1; i >= 0; i--) {
var idx = removedIdxs[i]; var idx = removedIdxs[i];
if (idx !== undefined) { if (idx !== undefined) {
this._detachAndRemoveInstance(idx); this._detachAndRemoveInstance(idx);
@ -4222,7 +4352,7 @@ addedKeys.sort(function (a, b) {
return self._sortFn(c.getItem(a), c.getItem(b)); return self._sortFn(c.getItem(a), c.getItem(b));
}); });
var start = 0; var start = 0;
for (var i = 0; i < addedKeys.length; i++) { for (i = 0; i < addedKeys.length; i++) {
start = this._insertRowUserSort(start, addedKeys[i]); start = this._insertRowUserSort(start, addedKeys[i]);
} }
} }
@ -4252,12 +4382,11 @@ this._insertPlaceholder(idx, key);
return idx; return idx;
}, },
_applySplicesArrayOrder: function (splices) { _applySplicesArrayOrder: function (splices) {
var c = this.collection;
for (var i = 0, s; i < splices.length && (s = splices[i]); i++) { for (var i = 0, s; i < splices.length && (s = splices[i]); i++) {
for (var j = 0; j < s.removed.length; j++) { for (var j = 0; j < s.removed.length; j++) {
this._detachAndRemoveInstance(s.index); this._detachAndRemoveInstance(s.index);
} }
for (var j = 0; j < s.addedKeys.length; j++) { for (j = 0; j < s.addedKeys.length; j++) {
this._insertPlaceholder(s.index + j, s.addedKeys[j]); this._insertPlaceholder(s.index + j, s.addedKeys[j]);
} }
} }