Encapsulate class directives in the stylesheet.

pull/1695/head
Jacob Wright 7 years ago
parent 4ec85bb8cc
commit c1fc9c1ac9

@ -157,7 +157,7 @@ function applySelector(stylesheet: Stylesheet, blocks: Block[], node: Node, stac
} }
if (selector.type === 'ClassSelector') { if (selector.type === 'ClassSelector') {
if (!attributeMatches(node, 'class', selector.name, '~=', false)) return false; if (!attributeMatches(node, 'class', selector.name, '~=', false) && !classMatches(node, selector.name)) return false;
} }
else if (selector.type === 'IdSelector') { else if (selector.type === 'IdSelector') {
@ -258,6 +258,12 @@ function attributeMatches(node: Node, name: string, expectedValue: string, opera
return false; return false;
} }
function classMatches(node, name: string) {
return node.classes.some(function(classDir) {
return classDir.name === name;
});
}
function isDynamic(value: Node) { function isDynamic(value: Node) {
return value.length > 1 || value[0].type !== 'Text'; return value.length > 1 || value[0].type !== 'Text';
} }

Loading…
Cancel
Save