Index: third_party/polymer/components/polymer/polymer.html |
diff --git a/third_party/polymer/components/polymer/polymer.html b/third_party/polymer/components/polymer/polymer.html |
index 61f81beb844160c43aa3d89e0f7e3a890062bd4c..0901e4e2462857bb71d7c7bb2f6077ce1e0aafd1 100644 |
--- a/third_party/polymer/components/polymer/polymer.html |
+++ b/third_party/polymer/components/polymer/polymer.html |
@@ -257,65 +257,6 @@ return root; |
} |
} |
}; |
-}());(function () { |
-function resolveCss(cssText, ownerDocument) { |
-return cssText.replace(CSS_URL_RX, function (m, pre, url, post) { |
-return pre + '\'' + resolve(url.replace(/["']/g, ''), ownerDocument) + '\'' + post; |
-}); |
-} |
-function resolveAttrs(element, ownerDocument) { |
-for (var name in URL_ATTRS) { |
-var a$ = URL_ATTRS[name]; |
-for (var i = 0, l = a$.length, a, at, v; i < l && (a = a$[i]); i++) { |
-if (name === '*' || element.localName === name) { |
-at = element.attributes[a]; |
-v = at && at.value; |
-if (v && v.search(BINDING_RX) < 0) { |
-at.value = a === 'style' ? resolveCss(v, ownerDocument) : resolve(v, ownerDocument); |
-} |
-} |
-} |
-} |
-} |
-function resolve(url, ownerDocument) { |
-if (url && ABS_URL.test(url)) { |
-return url; |
-} |
-var resolver = getUrlResolver(ownerDocument); |
-resolver.href = url; |
-return resolver.href || url; |
-} |
-var tempDoc; |
-var tempDocBase; |
-function resolveUrl(url, baseUri) { |
-if (!tempDoc) { |
-tempDoc = document.implementation.createHTMLDocument('temp'); |
-tempDocBase = tempDoc.createElement('base'); |
-tempDoc.head.appendChild(tempDocBase); |
-} |
-tempDocBase.href = baseUri; |
-return resolve(url, tempDoc); |
-} |
-function getUrlResolver(ownerDocument) { |
-return ownerDocument.body.__urlResolver || (ownerDocument.body.__urlResolver = ownerDocument.createElement('a')); |
-} |
-var CSS_URL_RX = /(url\()([^)]*)(\))/g; |
-var URL_ATTRS = { |
-'*': [ |
-'href', |
-'src', |
-'style', |
-'url' |
-], |
-form: ['action'] |
-}; |
-var ABS_URL = /(^\/)|(^#)|(^[\w-\d]*:)/; |
-var BINDING_RX = /\{\{|\[\[/; |
-Polymer.ResolveUrl = { |
-resolveCss: resolveCss, |
-resolveAttrs: resolveAttrs, |
-resolveUrl: resolveUrl |
-}; |
}());Polymer.Path = { |
root: function (path) { |
var dotIndex = path.indexOf('.'); |
@@ -2101,6 +2042,8 @@ node._configValue(name, value); |
} |
}, |
_afterClientsReady: function () { |
+this.importPath = this._importPath; |
+this.rootPath = Polymer.rootPath; |
this._executeStaticEffects(); |
this._applyConfig(this._config, this._aboveConfig); |
this._flushHandlers(); |
@@ -2439,13 +2382,7 @@ _getPathParts: Polymer.Base._getPathParts |
}); |
}());Polymer.Base._addFeature({ |
resolveUrl: function (url) { |
-var module = Polymer.DomModule.import(this.is); |
-var root = ''; |
-if (module) { |
-var assetPath = module.getAttribute('assetpath') || ''; |
-root = Polymer.ResolveUrl.resolveUrl(assetPath, module.ownerDocument.baseURI); |
-} |
-return Polymer.ResolveUrl.resolveUrl(url, root); |
+return Polymer.ResolveUrl.resolveUrl(url, this._importPath); |
} |
});Polymer.CssParse = function () { |
return { |
@@ -3028,6 +2965,11 @@ this._transformRule(rule, this._transformDocumentSelector); |
}, |
normalizeRootSelector: function (rule) { |
rule.selector = rule.selector.replace(ROOT, 'html'); |
+var parts = rule.selector.split(COMPLEX_SELECTOR_SEP); |
+parts = parts.filter(function (part) { |
+return !part.match(HOST_OR_HOST_GT_STAR); |
+}); |
+rule.selector = parts.join(COMPLEX_SELECTOR_SEP); |
}, |
_transformDocumentSelector: function (selector) { |
return selector.match(SCOPE_JUMP) ? this._transformComplexSelector(selector, SCOPE_DOC_SELECTOR) : this._transformSimpleSelector(selector.trim(), SCOPE_DOC_SELECTOR); |
@@ -3057,6 +2999,7 @@ var CLASS = 'class'; |
var CONTENT_START = new RegExp('^(' + CONTENT + ')'); |
var SELECTOR_NO_MATCH = 'should_not_match'; |
var SLOTTED_PAREN = /(?:::slotted)(?:\(((?:\([^)(]*\)|[^)(]*)+?)\))/g; |
+var HOST_OR_HOST_GT_STAR = /:host(?:\s*>\s*\*)?/; |
return api; |
}();Polymer.StyleExtends = function () { |
var styleUtil = Polymer.StyleUtil; |
@@ -4770,9 +4713,17 @@ this._detachInstance(i); |
attached: function () { |
if (this.__isDetached) { |
this.__isDetached = false; |
-var parent = Polymer.dom(Polymer.dom(this).parentNode); |
+var refNode; |
+var parentNode = Polymer.dom(this).parentNode; |
+if (parentNode.localName == this.is) { |
+refNode = parentNode; |
+parentNode = Polymer.dom(parentNode).parentNode; |
+} else { |
+refNode = this; |
+} |
+var parent = Polymer.dom(parentNode); |
for (var i = 0; i < this._instances.length; i++) { |
-this._attachInstance(i, parent); |
+this._attachInstance(i, parent, refNode); |
} |
} |
}, |
@@ -5056,10 +5007,10 @@ Polymer.dom(inst.root).appendChild(el); |
return inst; |
} |
}, |
-_attachInstance: function (idx, parent) { |
+_attachInstance: function (idx, parent, refNode) { |
var inst = this._instances[idx]; |
if (!inst.isPlaceholder) { |
-parent.insertBefore(inst.root, this); |
+parent.insertBefore(inst.root, refNode); |
} |
}, |
_detachAndRemoveInstance: function (idx) { |
@@ -5092,6 +5043,12 @@ inst = this._stampInstance(idx, key); |
var beforeRow = this._instances[idx + 1]; |
var beforeNode = beforeRow && !beforeRow.isPlaceholder ? beforeRow._children[0] : this; |
var parentNode = Polymer.dom(this).parentNode; |
+if (parentNode.localName == this.is) { |
+if (beforeNode == this) { |
+beforeNode = parentNode; |
+} |
+parentNode = Polymer.dom(parentNode).parentNode; |
+} |
Polymer.dom(parentNode).insertBefore(inst.root, beforeNode); |
this._instances[idx] = inst; |
return inst; |
@@ -5287,7 +5244,11 @@ _queueRender: function () { |
this._debounceTemplate(this._render); |
}, |
detached: function () { |
-if (!this.parentNode || this.parentNode.nodeType == Node.DOCUMENT_FRAGMENT_NODE && (!Polymer.Settings.hasShadow || !(this.parentNode instanceof ShadowRoot))) { |
+var parentNode = this.parentNode; |
+if (parentNode && parentNode.localName == this.is) { |
+parentNode = Polymer.dom(parentNode).parentNode; |
+} |
+if (!parentNode || parentNode.nodeType == Node.DOCUMENT_FRAGMENT_NODE && (!Polymer.Settings.hasShadow || !(parentNode instanceof ShadowRoot))) { |
this._teardownInstance(); |
} |
}, |
@@ -5320,20 +5281,26 @@ this._lastIf = this.if; |
} |
}, |
_ensureInstance: function () { |
+var refNode; |
var parentNode = Polymer.dom(this).parentNode; |
+if (parentNode && parentNode.localName == this.is) { |
+refNode = parentNode; |
+parentNode = Polymer.dom(parentNode).parentNode; |
+} else { |
+refNode = this; |
+} |
if (parentNode) { |
-var parent = Polymer.dom(parentNode); |
if (!this._instance) { |
this._instance = this.stamp(); |
var root = this._instance.root; |
-parent.insertBefore(root, this); |
+Polymer.dom(parentNode).insertBefore(root, refNode); |
} else { |
var c$ = this._instance._children; |
if (c$ && c$.length) { |
-var lastChild = Polymer.dom(this).previousSibling; |
+var lastChild = Polymer.dom(refNode).previousSibling; |
if (lastChild !== c$[c$.length - 1]) { |
for (var i = 0, n; i < c$.length && (n = c$[i]); i++) { |
-parent.insertBefore(n, this); |
+Polymer.dom(parentNode).insertBefore(n, refNode); |
} |
} |
} |
@@ -5398,8 +5365,15 @@ _registerFeatures: function () { |
this._prepConstructor(); |
}, |
_insertChildren: function () { |
-var parentDom = Polymer.dom(Polymer.dom(this).parentNode); |
-parentDom.insertBefore(this.root, this); |
+var refNode; |
+var parentNode = Polymer.dom(this).parentNode; |
+if (parentNode.localName == this.is) { |
+refNode = parentNode; |
+parentNode = Polymer.dom(parentNode).parentNode; |
+} else { |
+refNode = this; |
+} |
+Polymer.dom(parentNode).insertBefore(this.root, refNode); |
}, |
_removeChildren: function () { |
if (this._children) { |
@@ -5465,4 +5439,3 @@ this.fire('dom-change'); |
- |