be conservative for now

pull/10502/head
Rich Harris 3 years ago
parent 76ca6d4408
commit a03849cd35

@ -160,6 +160,7 @@ function apply_selector(relative_selectors, rule, element, stylesheet) {
/** @type {import('#compiler').TemplateNode | null} */ /** @type {import('#compiler').TemplateNode | null} */
let parent = element; let parent = element;
let crossed_component_boundary = false; let crossed_component_boundary = false;
let matched = false;
while ((parent = /** @type {import('#compiler').TemplateNode | null} */ (parent.parent))) { while ((parent = /** @type {import('#compiler').TemplateNode | null} */ (parent.parent))) {
if (parent.type === 'Component' || parent.type === 'SvelteComponent') { if (parent.type === 'Component' || parent.type === 'SvelteComponent') {
@ -167,7 +168,7 @@ function apply_selector(relative_selectors, rule, element, stylesheet) {
// ensure that any _other_ elements that use this selector end up getting scoped // ensure that any _other_ elements that use this selector end up getting scoped
// e.g. if you have `<x><y><z>` and `<x><Y><z>`, we need to make sure that the // e.g. if you have `<x><y><z>` and `<x><Y><z>`, we need to make sure that the
// `y` selector gets scoped // `y` selector gets scoped, otherwise it might falsely apply to `<Y>`
relative_selectors[relative_selectors.length - 1].metadata.scoped = true; relative_selectors[relative_selectors.length - 1].metadata.scoped = true;
} }
@ -176,15 +177,16 @@ function apply_selector(relative_selectors, rule, element, stylesheet) {
if (crossed_component_boundary) { if (crossed_component_boundary) {
mark(relative_selectors[relative_selectors.length - 1], parent); mark(relative_selectors[relative_selectors.length - 1], parent);
} else { } else {
relative_selector.metadata.selected.add(element); mark(relative_selectors[relative_selectors.length - 1], parent);
// relative_selector.metadata.selected.add(element);
} }
return true; matched = true;
} }
} }
} }
return false; return matched;
} }
if (relative_selector.combinator.name === '>') { if (relative_selector.combinator.name === '>') {

@ -30,6 +30,7 @@ const svelte_modules = glob('**/*.svelte', { cwd: `${cwd}/input` });
const js_modules = glob('**/*.js', { cwd: `${cwd}/input` }); const js_modules = glob('**/*.js', { cwd: `${cwd}/input` });
for (const generate of ['client', 'server']) { for (const generate of ['client', 'server']) {
console.error(`\n--- generating ${generate} ---\n`);
for (const file of svelte_modules) { for (const file of svelte_modules) {
const input = `${cwd}/input/${file}`; const input = `${cwd}/input/${file}`;
const source = fs.readFileSync(input, 'utf-8'); const source = fs.readFileSync(input, 'utf-8');

Loading…
Cancel
Save