style dom-module's support only 1 template.

This commit is contained in:
Steven Orvell 2017-02-27 17:06:24 -08:00
parent 6c51b2a0e7
commit 4943f865a7

View File

@ -29,31 +29,31 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
* @param {boolean=} warnIfNotFound
* @return {string}
*/
cssFromModules(moduleIds, warnIfNotFound) {
cssFromModules(moduleIds) {
let modules = moduleIds.trim().split(' ');
let cssText = '';
for (let i=0; i < modules.length; i++) {
cssText += this.cssFromModule(modules[i], warnIfNotFound);
cssText += this.cssFromModule(modules[i]);
}
return cssText;
},
// returns cssText of styles in a given module; also un-applies any
// styles that apply to the document.
cssFromModule(moduleId, warnIfNotFound) {
cssFromModule(moduleId) {
let m = importModule(moduleId);
if (m && m._cssText === undefined) {
let cssText = '';
let t$ = m.querySelectorAll('template');
// include css from any templates in the module
for (let i=0; i < t$.length; i++) {
cssText += this.cssFromTemplate(t$[i]);
// include css from the first template in the module
let t = m.querySelector('template');
if (t) {
cssText += this.cssFromTemplate(t);
}
// module imports: <link rel="import" type="css">
cssText += this.cssFromModuleImports(moduleId);
m._cssText = cssText || null;
}
if (!m && warnIfNotFound) {
if (!m) {
console.warn('Could not find style data in module named', moduleId);
}
return m && m._cssText || '';
@ -70,7 +70,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
// other dom-modules that contain styling
let include = e.getAttribute(INCLUDE_ATTR);
if (include) {
cssText += this.cssFromModules(include, true);
cssText += this.cssFromModules(include);
}
e.parentNode.removeChild(e);
cssText +=