Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Commit

Permalink
Don't mark templates in polymer v1 builds
Browse files Browse the repository at this point in the history
Backport of ba3df1b
  • Loading branch information
dfreedm committed Sep 13, 2018
1 parent ea7aaff commit 5430312
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,16 @@ function addClass(node, className) {
dom5.setAttribute(node, 'class', classList.join(' '));
}

function markElement(domModule, scope, useNativeShadow) {
function markElement(domModule, scope, useNativeShadow, markTemplate = true) {
const buildType = useNativeShadow ? 'shadow' : 'shady';
// apply scoping to dom-module
dom5.setAttribute(domModule, 'css-build', buildType);
// apply scoping to template
const template = dom5.query(domModule, pred.hasTagName('template'));
if (template) {
dom5.setAttribute(template, 'css-build', buildType);
if (markTemplate) {
dom5.setAttribute(template, 'css-build', buildType);
}
// mark elements' subtree under shady build
if (buildType === 'shady' && scope) {
const elements = dom5.queryAll(template, notStyleMatch, undefined, dom5.childNodesIncludeTemplate);
Expand Down Expand Up @@ -319,7 +321,7 @@ async function polymerCssBuild(paths, options = {}) {
const el = getAstNode(domModule);
domModuleCache[scope] = el;
setNodeFileLocation(el, domModule);
markElement(el, scope, nativeShadow);
markElement(el, scope, nativeShadow, polymerVersion > 1);
const styles = getAndFixDomModuleStyles(el);
styles.forEach((s) => {
scopeMap.set(s, scope);
Expand Down
4 changes: 3 additions & 1 deletion tests/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@
const dm = Polymer.DomModule.import('x-app');
assert(dm.hasAttribute('css-build'), 'dom-module should have css-build attribute');
const template = dm.querySelector('template');
assert(template.hasAttribute('css-build'), 'dom-module template should have css-build attribute');
if (Polymer.Element) {
assert(template.hasAttribute('css-build'), 'dom-module template should have css-build attribute');
}
});
});
</script>

0 comments on commit 5430312

Please sign in to comment.