diff --git a/src/lib/resolve-url.html b/src/lib/resolve-url.html index 6b1b358c5b..74fc5f43fc 100644 --- a/src/lib/resolve-url.html +++ b/src/lib/resolve-url.html @@ -67,6 +67,16 @@ (ownerDocument.body.__urlResolver = ownerDocument.createElement('a')); } + /** + * Returns a path from a given `url`. The path includes the trailing + * `/` from the url. + * @param {string} url Input URL to transform + * @return {string} resolved path + */ + function pathFromUrl(url) { + return url.substring(0, url.lastIndexOf('/') + 1); + } + var CSS_URL_RX = /(url\()([^)]*)(\))/g; var URL_ATTRS = { '*': ['href', 'src', 'style', 'url'], @@ -79,9 +89,13 @@ Polymer.ResolveUrl = { resolveCss: resolveCss, resolveAttrs: resolveAttrs, - resolveUrl: resolveUrl + resolveUrl: resolveUrl, + pathFromUrl: pathFromUrl }; + // NOTE: IE11 does not support baseURI + Polymer.rootPath = pathFromUrl(document.baseURI || window.location.href); + })(); diff --git a/src/mini/template.html b/src/mini/template.html index c6e1296cbb..ca9587e29f 100644 --- a/src/mini/template.html +++ b/src/mini/template.html @@ -7,6 +7,7 @@ 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 --> + diff --git a/test/unit/sub/resolveurl-elements.html b/test/unit/sub/resolveurl-elements.html index 1fab8e53b4..6503acb256 100644 --- a/test/unit/sub/resolveurl-elements.html +++ b/test/unit/sub/resolveurl-elements.html @@ -31,6 +31,31 @@ Polymer({is: 'p-r'}); + + + + +