@stylable/core
Advanced tools
Comparing version 3.2.1 to 3.3.0
@@ -45,2 +45,3 @@ import postcss from 'postcss'; | ||
protected handleAtRules(root: postcss.Root): void; | ||
private handleNamespaceReference; | ||
protected handleRule(rule: SRule, inStScope?: boolean): void; | ||
@@ -47,0 +48,0 @@ protected checkRedeclareSymbol(symbolName: string, node: postcss.Node): void; |
@@ -147,3 +147,6 @@ "use strict"; | ||
atRule.walkRules(rule => { | ||
rule.replaceWith(rule.clone({ selector: `${scopingRule.selector} ${rule.selector}` })); | ||
rule.replaceWith(rule.clone({ | ||
selector: stylable_utils_1.scopeSelector(scopingRule.selector, rule.selector, false) | ||
.selector | ||
})); | ||
}); | ||
@@ -244,4 +247,18 @@ } | ||
namespace = namespace || utils_1.filename2varname(path_1.default.basename(this.meta.source)) || 's'; | ||
this.meta.namespace = this.resolveNamespace(namespace, this.meta.source); | ||
this.meta.namespace = this.handleNamespaceReference(namespace); | ||
} | ||
handleNamespaceReference(namespace) { | ||
let pathToSource; | ||
this.meta.ast.walkComments(comment => { | ||
if (comment.text.includes('st-namespace-reference')) { | ||
const namespaceReferenceParts = comment.text.split('='); | ||
pathToSource = utils_1.stripQuotation(namespaceReferenceParts[namespaceReferenceParts.length - 1]); | ||
return false; | ||
} | ||
return undefined; | ||
}); | ||
return this.resolveNamespace(namespace, pathToSource | ||
? path_1.default.resolve(path_1.default.dirname(this.meta.source), pathToSource) | ||
: this.meta.source); | ||
} | ||
handleRule(rule, inStScope = false) { | ||
@@ -248,0 +265,0 @@ rule.selectorAst = selector_utils_1.parseSelector(rule.selector); |
{ | ||
"name": "@stylable/core", | ||
"version": "3.2.1", | ||
"version": "3.3.0", | ||
"description": "CSS for Components", | ||
@@ -15,3 +15,3 @@ "main": "./cjs/index.js", | ||
"dependencies": { | ||
"css-selector-tokenizer": "^0.7.1", | ||
"css-selector-tokenizer": "^0.7.2", | ||
"deindent": "^0.1.0", | ||
@@ -48,3 +48,3 @@ "enhanced-resolve": "^4.1.1", | ||
"license": "BSD-3-Clause", | ||
"gitHead": "508088f302c67f2837256a5c37ade110352146ea" | ||
"gitHead": "a84e57e76b8a1fd81d8ce5f0ffb3a3e2f3cb66e6" | ||
} |
@@ -31,3 +31,4 @@ import hash from 'murmurhash'; | ||
getAlias, | ||
isCSSVarProp | ||
isCSSVarProp, | ||
scopeSelector | ||
} from './stylable-utils'; | ||
@@ -185,3 +186,6 @@ import { | ||
rule.replaceWith( | ||
rule.clone({ selector: `${scopingRule.selector} ${rule.selector}` }) | ||
rule.clone({ | ||
selector: scopeSelector(scopingRule.selector, rule.selector, false) | ||
.selector | ||
}) | ||
); | ||
@@ -294,5 +298,26 @@ }); | ||
namespace = namespace || filename2varname(path.basename(this.meta.source)) || 's'; | ||
this.meta.namespace = this.resolveNamespace(namespace, this.meta.source); | ||
this.meta.namespace = this.handleNamespaceReference(namespace); | ||
} | ||
private handleNamespaceReference(namespace: string): string { | ||
let pathToSource: string | undefined; | ||
this.meta.ast.walkComments(comment => { | ||
if (comment.text.includes('st-namespace-reference')) { | ||
const namespaceReferenceParts = comment.text.split('='); | ||
pathToSource = stripQuotation( | ||
namespaceReferenceParts[namespaceReferenceParts.length - 1] | ||
); | ||
return false; | ||
} | ||
return undefined; | ||
}); | ||
return this.resolveNamespace( | ||
namespace, | ||
pathToSource | ||
? path.resolve(path.dirname(this.meta.source), pathToSource) | ||
: this.meta.source | ||
); | ||
} | ||
protected handleRule(rule: SRule, inStScope = false) { | ||
@@ -299,0 +324,0 @@ rule.selectorAst = parseSelector(rule.selector); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
658238
11387