OLD | NEW |
1 Polymer.Base._addFeature({ | 1 (function () { |
| 2 function resolveCss(cssText, ownerDocument) { |
| 3 return cssText.replace(CSS_URL_RX, function (m, pre, url, post) { |
| 4 return pre + '\'' + resolve(url.replace(/["']/g, ''), ownerDocument) + '\'' + po
st; |
| 5 }); |
| 6 } |
| 7 function resolveAttrs(element, ownerDocument) { |
| 8 for (var name in URL_ATTRS) { |
| 9 var a$ = URL_ATTRS[name]; |
| 10 for (var i = 0, l = a$.length, a, at, v; i < l && (a = a$[i]); i++) { |
| 11 if (name === '*' || element.localName === name) { |
| 12 at = element.attributes[a]; |
| 13 v = at && at.value; |
| 14 if (v && v.search(BINDING_RX) < 0) { |
| 15 at.value = a === 'style' ? resolveCss(v, ownerDocument) : resolve(v, ownerDocume
nt); |
| 16 } |
| 17 } |
| 18 } |
| 19 } |
| 20 } |
| 21 function resolve(url, ownerDocument) { |
| 22 if (url && ABS_URL.test(url)) { |
| 23 return url; |
| 24 } |
| 25 var resolver = getUrlResolver(ownerDocument); |
| 26 resolver.href = url; |
| 27 return resolver.href || url; |
| 28 } |
| 29 var tempDoc; |
| 30 var tempDocBase; |
| 31 function resolveUrl(url, baseUri) { |
| 32 if (!tempDoc) { |
| 33 tempDoc = document.implementation.createHTMLDocument('temp'); |
| 34 tempDocBase = tempDoc.createElement('base'); |
| 35 tempDoc.head.appendChild(tempDocBase); |
| 36 } |
| 37 tempDocBase.href = baseUri; |
| 38 return resolve(url, tempDoc); |
| 39 } |
| 40 function getUrlResolver(ownerDocument) { |
| 41 return ownerDocument.body.__urlResolver || (ownerDocument.body.__urlResolver = o
wnerDocument.createElement('a')); |
| 42 } |
| 43 function pathFromUrl(url) { |
| 44 return url.substring(0, url.lastIndexOf('/') + 1); |
| 45 } |
| 46 var CSS_URL_RX = /(url\()([^)]*)(\))/g; |
| 47 var URL_ATTRS = { |
| 48 '*': [ |
| 49 'href', |
| 50 'src', |
| 51 'style', |
| 52 'url' |
| 53 ], |
| 54 form: ['action'] |
| 55 }; |
| 56 var ABS_URL = /(^\/)|(^#)|(^[\w-\d]*:)/; |
| 57 var BINDING_RX = /\{\{|\[\[/; |
| 58 Polymer.ResolveUrl = { |
| 59 resolveCss: resolveCss, |
| 60 resolveAttrs: resolveAttrs, |
| 61 resolveUrl: resolveUrl, |
| 62 pathFromUrl: pathFromUrl |
| 63 }; |
| 64 Polymer.rootPath = Polymer.Settings.rootPath || pathFromUrl(document.baseURI ||
window.location.href); |
| 65 }());Polymer.Base._addFeature({ |
2 _prepTemplate: function () { | 66 _prepTemplate: function () { |
| 67 var module; |
3 if (this._template === undefined) { | 68 if (this._template === undefined) { |
4 this._template = Polymer.DomModule.import(this.is, 'template'); | 69 module = Polymer.DomModule.import(this.is); |
| 70 this._template = module && module.querySelector('template'); |
| 71 } |
| 72 if (module) { |
| 73 var assetPath = module.getAttribute('assetpath') || ''; |
| 74 var importURL = Polymer.ResolveUrl.resolveUrl(assetPath, module.ownerDocument.ba
seURI); |
| 75 this._importPath = Polymer.ResolveUrl.pathFromUrl(importURL); |
| 76 } else { |
| 77 this._importPath = ''; |
5 } | 78 } |
6 if (this._template && this._template.hasAttribute('is')) { | 79 if (this._template && this._template.hasAttribute('is')) { |
7 this._warn(this._logf('_prepTemplate', 'top-level Polymer template ' + 'must not
be a type-extension, found', this._template, 'Move inside simple <template>.'))
; | 80 this._warn(this._logf('_prepTemplate', 'top-level Polymer template ' + 'must not
be a type-extension, found', this._template, 'Move inside simple <template>.'))
; |
8 } | 81 } |
9 if (this._template && !this._template.content && window.HTMLTemplateElement && H
TMLTemplateElement.decorate) { | 82 if (this._template && !this._template.content && window.HTMLTemplateElement && H
TMLTemplateElement.decorate) { |
10 HTMLTemplateElement.decorate(this._template); | 83 HTMLTemplateElement.decorate(this._template); |
11 } | 84 } |
12 }, | 85 }, |
13 _stampTemplate: function () { | 86 _stampTemplate: function () { |
14 if (this._template) { | 87 if (this._template) { |
(...skipping 2127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2142 this._endHosting(); | 2215 this._endHosting(); |
2143 } | 2216 } |
2144 this._marshalHostAttributes(); | 2217 this._marshalHostAttributes(); |
2145 this._setupDebouncers(); | 2218 this._setupDebouncers(); |
2146 this._marshalBehaviors(); | 2219 this._marshalBehaviors(); |
2147 this._tryReady(); | 2220 this._tryReady(); |
2148 }, | 2221 }, |
2149 _marshalBehavior: function (b) { | 2222 _marshalBehavior: function (b) { |
2150 } | 2223 } |
2151 }); | 2224 }); |
OLD | NEW |