update components
This commit is contained in:
parent
4f69bbfb13
commit
36d7dc70f3
7 changed files with 98 additions and 51 deletions
|
@ -1,5 +1,13 @@
|
|||
<!--
|
||||
@license
|
||||
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
--><!--
|
||||
@license
|
||||
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
|
@ -1659,7 +1667,12 @@ if (prop.notify) {
|
|||
this._addPropertyEffect(p, 'notify', { event: Polymer.CaseMap.camelToDashCase(p) + '-changed' });
|
||||
}
|
||||
if (prop.reflectToAttribute) {
|
||||
this._addPropertyEffect(p, 'reflect', { attribute: Polymer.CaseMap.camelToDashCase(p) });
|
||||
var attr = Polymer.CaseMap.camelToDashCase(p);
|
||||
if (attr[0] === '-') {
|
||||
this._warn(this._logf('_addPropertyEffects', 'Property ' + p + ' cannot be reflected to attribute ' + attr + ' because "-" is not a valid starting attribute name. Use a lowercase first letter for the property instead.'));
|
||||
} else {
|
||||
this._addPropertyEffect(p, 'reflect', { attribute: attr });
|
||||
}
|
||||
}
|
||||
if (prop.readOnly) {
|
||||
Polymer.Bind.ensurePropertyEffects(this, p);
|
||||
|
@ -1742,6 +1755,9 @@ var part = note.parts[i];
|
|||
if (part.signature) {
|
||||
this._addAnnotatedComputationEffect(note, part, index);
|
||||
} else if (!part.literal) {
|
||||
if (note.kind === 'attribute' && note.name[0] === '-') {
|
||||
this._warn(this._logf('_addAnnotationEffect', 'Cannot set attribute ' + note.name + ' because "-" is not a valid attribute starting character'));
|
||||
} else {
|
||||
this._addPropertyEffect(part.model, 'annotation', {
|
||||
kind: note.kind,
|
||||
index: index,
|
||||
|
@ -1756,6 +1772,7 @@ negate: part.negate
|
|||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
_addAnnotatedComputationEffect: function (note, part, index) {
|
||||
var sig = part.signature;
|
||||
|
@ -2525,20 +2542,30 @@ this.forEachRule(r, styleRuleCallback, keyframesRuleCallback);
|
|||
}
|
||||
}
|
||||
},
|
||||
applyCss: function (cssText, moniker, target, afterNode) {
|
||||
applyCss: function (cssText, moniker, target, contextNode) {
|
||||
var style = this.createScopeStyle(cssText, moniker);
|
||||
target = target || document.head;
|
||||
var after = contextNode && contextNode.nextSibling || target.firstChild;
|
||||
this.__lastHeadApplyNode = style;
|
||||
return target.insertBefore(style, after);
|
||||
},
|
||||
createScopeStyle: function (cssText, moniker) {
|
||||
var style = document.createElement('style');
|
||||
if (moniker) {
|
||||
style.setAttribute('scope', moniker);
|
||||
}
|
||||
style.textContent = cssText;
|
||||
target = target || document.head;
|
||||
if (!afterNode) {
|
||||
var n$ = target.querySelectorAll('style[scope]');
|
||||
afterNode = n$[n$.length - 1];
|
||||
}
|
||||
target.insertBefore(style, afterNode && afterNode.nextSibling || target.firstChild);
|
||||
return style;
|
||||
},
|
||||
__lastHeadApplyNode: null,
|
||||
applyStylePlaceHolder: function (moniker) {
|
||||
var placeHolder = document.createComment(' Shady DOM styles for ' + moniker + ' ');
|
||||
var after = this.__lastHeadApplyNode ? this.__lastHeadApplyNode.nextSibling : null;
|
||||
var scope = document.head;
|
||||
scope.insertBefore(placeHolder, after || scope.firstChild);
|
||||
this.__lastHeadApplyNode = placeHolder;
|
||||
return placeHolder;
|
||||
},
|
||||
cssFromModules: function (moduleIds, warnIfNotFound) {
|
||||
var modules = moduleIds.trim().split(' ');
|
||||
var cssText = '';
|
||||
|
@ -2855,20 +2882,20 @@ styleTransformer.element(element, this.is, this._scopeCssViaAttr);
|
|||
prepElement.call(this, element);
|
||||
},
|
||||
_prepStyles: function () {
|
||||
if (this._encapsulateStyle === undefined) {
|
||||
this._encapsulateStyle = !nativeShadow && Boolean(this._template);
|
||||
if (!nativeShadow) {
|
||||
this._scopeStyle = styleUtil.applyStylePlaceHolder(this.is);
|
||||
}
|
||||
},
|
||||
_prepShimStyles: function () {
|
||||
if (this._template) {
|
||||
if (this._encapsulateStyle === undefined) {
|
||||
this._encapsulateStyle = !nativeShadow;
|
||||
}
|
||||
this._styles = this._collectStyles();
|
||||
var cssText = styleTransformer.elementStyles(this);
|
||||
this._prepStyleProperties();
|
||||
var needsStatic = this._styles.length && !this._needsStyleProperties();
|
||||
if (needsStatic || !nativeShadow) {
|
||||
cssText = needsStatic ? cssText : ' ';
|
||||
var style = styleUtil.applyCss(cssText, this.is, nativeShadow ? this._template.content : null);
|
||||
if (!nativeShadow) {
|
||||
this._scopeStyle = style;
|
||||
}
|
||||
if (!this._needsStyleProperties() && this._styles.length) {
|
||||
styleUtil.applyCss(cssText, this.is, nativeShadow ? this._template.content : null, this._scopeStyle);
|
||||
}
|
||||
} else {
|
||||
this._styles = [];
|
||||
|
@ -3511,8 +3538,11 @@ Polymer.Base._addFeature({
|
|||
_registerFeatures: function () {
|
||||
this._prepIs();
|
||||
this._prepConstructor();
|
||||
this._prepTemplate();
|
||||
this._prepStyles();
|
||||
},
|
||||
_finishRegisterFeatures: function () {
|
||||
this._prepTemplate();
|
||||
this._prepShimStyles();
|
||||
this._prepAnnotations();
|
||||
this._prepEffects();
|
||||
this._prepBehaviors();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue