diff --git a/tests/NativeWeb/compiler_tests.py b/tests/NativeWeb/compiler_tests.py index bc42cd3f3..3add52e4d 100644 --- a/tests/NativeWeb/compiler_tests.py +++ b/tests/NativeWeb/compiler_tests.py @@ -88,6 +88,21 @@ def test_prepared_rule_classification_is_emitted(self): self.assertEqual(generated.count('r->host_selector=1;'),1) self.assertEqual(generated.count('r->host_selector=0;'),len(selectors)-1) + def test_prepared_selector_structures_are_emitted(self): + with tempfile.TemporaryDirectory() as folder: + root=pathlib.Path(folder);source=root/'selectors.css';output=root/'selectors.cppm' + source.write_text('@namespace p url("urn:webscene:test"); p|node[p|mode^="ready" i]:is(.active) {color:red}') + result=subprocess.run([UIC,'--prepare-css',source,output,'--module','test.selectors'],capture_output=True,text=True) + self.assertEqual(result.returncode,0,result.stderr) + generated=output.read_text() + self.assertIn('c.namespace_uri="urn:webscene:test";',generated) + self.assertIn('a.local_name="mode";',generated) + self.assertIn('a.namespace_uri="urn:webscene:test";',generated) + self.assertIn('a.operator_kind=4u;',generated) + self.assertIn('a.value="ready";',generated) + self.assertIn('a.case_sensitivity=1u;',generated) + self.assertIn('c.pseudos.push_back({"is",".active",{},1});',generated) + def test_opacity_transition_shorthand(self): for value in ['opacity 100ms linear 20ms', 'opacity .2s ease-in', 'none']: result, out = self.compile('
', 'div {transition:'+value+'}') diff --git a/tooling/webscene-uic/main.cpp b/tooling/webscene-uic/main.cpp index 75ba24db3..4e3aac80c 100644 --- a/tooling/webscene-uic/main.cpp +++ b/tooling/webscene-uic/main.cpp @@ -1861,12 +1861,23 @@ static void emit_prepared_selector(std::ostream& out, std::string_view target, for(const auto& compound:selector.compiled_compounds) { out << "{webscene_native::css::compiled_css_compound c;\nc.tag=" << quote(compound.tag) << ";c.valid=" << compound.valid << ";c.pseudo_element=" << compound.pseudo_element << ";\n"; + if(compound.namespace_uri.has_value()) + out << "c.namespace_uri=" << quote(*compound.namespace_uri) << ";\n"; for(const auto& [kind,name]:compound.identities) out << "c.identities.emplace_back(static_cast