Skip to content

Commit 12a4bcd

Browse files
authored
Merge pull request #4291 from Polymer/2.0-dom-module-assetpath
set assetpath
2 parents 20de60f + db5cfb3 commit 12a4bcd

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/elements/element.html

+1-2
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,8 @@
408408
var module = Polymer.DomModule.import(this.constructor.is);
409409
var root = '';
410410
if (module) {
411-
var assetPath = module.getAttribute('assetpath') || '';
412411
root = Polymer.ResolveUrl.resolveUrl(
413-
assetPath, module.ownerDocument.baseURI);
412+
module.assetpath, module.ownerDocument.baseURI);
414413
}
415414
return Polymer.ResolveUrl.resolveUrl(url, root);
416415
}

src/legacy/dom-module.html

+19
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,25 @@
4040
}
4141
}
4242

43+
get assetpath() {
44+
let assetpath = this.__assetpath || this.getAttribute('assetpath');
45+
// Don't override existing assetpath.
46+
if (assetpath) {}
47+
// Polyfilled import.
48+
else if (window.HTMLImports && !HTMLImports.useNative &&
49+
HTMLImports.importForElement) {
50+
const imp = HTMLImports.importForElement(this);
51+
assetpath = imp ? imp.href : '';
52+
}
53+
// Native import.
54+
else if (this.ownerDocument !== document && this.baseURI) {
55+
assetpath = this.baseURI;
56+
}
57+
// Memoize.
58+
this.__assetpath = assetpath;
59+
return assetpath;
60+
}
61+
4362
/**
4463
* Registers the dom-module at a given id. This method should only be called
4564
* when a dom-module is imperatively created. For

0 commit comments

Comments
 (0)