Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: first level pseudo-element def with extend in structure mode #2888

Merged
merged 1 commit into from
Jul 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions packages/core/src/stylable-transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -827,10 +827,15 @@ export class InferredSelector {
for (const resolvedContext of this.resolveSet.values()) {
/**
* search for elements in each resolved selector.
* start at 1 for extended symbols to prefer inherited elements over local
* start at 1 for legacy flat mode to prefer inherited elements over local
*/
const startIndex =
resolvedContext.length === 1 || resolvedContext[0]?.symbol._kind === 'part' ? 0 : 1;
resolvedContext.length === 1 ||
(resolvedContext[0] &&
(STStructure.isStructureMode(resolvedContext[0].meta) ||
resolvedContext[0].symbol._kind === 'part'))
? 0
: 1;
resolved: for (let i = startIndex; i < resolvedContext.length; i++) {
const { symbol, meta } = resolvedContext[i];
const structureMode = STStructure.isStructureMode(meta);
Expand Down
20 changes: 20 additions & 0 deletions packages/core/test/features/st-structure.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,26 @@ describe('@st structure', () => {

shouldReportNoDiagnostics(meta);
});
it('should resolve first level definition', () => {
const { sheets } = testStylableCore(`
@st .b {
@st ::title => & > h2;
}
@st .a :is(.b) {
@st ::title => & > h1;
}

/* @rule .entry__a > h1 */
.a::title {}

/* @rule .entry__b > h2 */
.b::title {}
`);

const { meta } = sheets['/entry.st.css'];

shouldReportNoDiagnostics(meta);
});
it('should resolve inherited parts', () => {
const { sheets } = testStylableCore({
'base.st.css': `
Expand Down