|
|
@ -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, ',').split(',');
|
|
|
|
var args = m[2].replace(/\\,/g, ',').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]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|