Repository navigation
Conversation
…e style declaration ## Description The Rust port had no DOM, so nothing could run `createDOM`, `exportDOM` or HTML import and export, and the `html/*` and `css/*` vectors were not replayed. A new `html` feature brings `lexical_editor::dom`, a small DOM ported from the Swift port's (`swift/Sources/Lexical/DOM`): `DomNode` (one shared handle for `Node`, `Element`, `Text`, `Comment`, `DocumentFragment` and `Document`), `DOMTokenList`, an inline `CSSStyleDeclaration` that normalizes values as jsdom's does and keeps the `style` attribute in step, `DOMParser` (a WHATWG tokenizer and the tree builder HTML import meets), the HTML fragment serializer, and one `document` per thread (`get_document`). The property and entity tables are generated from the vectors by `rust/scripts/generate-dom-tables.mjs`, as Swift's are. The core gets `utils/setDOMStyle.ts`: `getStyleObjectFromCSS` (always, with JS's property order for array-index keys) and, with `html`, `setDOMStyleObject` and `setDOMStyleFromCSS`. The conformance runner replays `html/parse`, `html/entities`, `css/properties` and `css/values`. For `css/properties` it checks the declaration's behavior with the same probes `css.test.ts` asks jsdom, not only the table; that showed that jsdom rejects a shadow of nothing but identifiers (`box-shadow: Foo`) and lower-cases CSS-wide keywords for every property, which the declaration now does. Swift's declaration keeps such shadows (its test compares only the table); that is fixed in Swift separately. ## Test plan ### Before ``` $ cargo run -q --release -p lexical-conformance | grep -E 'css/|html/|Total' | `css/properties` | – | – | – | – | – | not implemented | | `css/values` | – | – | – | – | – | not implemented | | `html/entities` | – | – | – | – | – | not implemented | | `html/export` | – | – | – | – | – | not implemented | | `html/import` | – | – | – | – | – | not implemented | | `html/parse` | – | – | – | – | – | not implemented | | **Total** | 488 | 488 | 0 | 0 | 0 | | ``` ### After ``` $ cargo run -q --release -p lexical-conformance | grep -E 'css/|html/|Total' | `css/properties` | 814 | 814 | 0 | 0 | 0 | pass | | `css/values` | 69 | 69 | 0 | 0 | 0 | pass | | `html/entities` | 2125 | 2125 | 0 | 0 | 0 | pass | | `html/export` | – | – | – | – | – | not implemented | | `html/import` | – | – | – | – | – | not implemented | | `html/parse` | 37 | 37 | 0 | 0 | 0 | pass | | **Total** | 3533 | 3533 | 0 | 0 | 0 | | $ cargo clippy --workspace --all-targets --all-features --locked -- -D warnings # clean $ cargo test --workspace --all-features --locked # all pass ``` Before the shadow fix, `css/properties` failed `box-shadow`, `-webkit-box-shadow` and `text-shadow` (`preserveCase: Rust true, JS false`). Amp-Thread-ID: https://ampcode.com/threads/T-506c8fa1-4309-40f1-9810-732b311eaeab
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The Rust port had no DOM, so nothing could run
createDOM,exportDOMor HTML import and export, and the
html/*andcss/*vectors were notreplayed.
A new
htmlfeature bringslexical_editor::dom, a small DOM ported fromthe Swift port's (
swift/Sources/Lexical/DOM):DomNode(one shared handlefor
Node,Element,Text,Comment,DocumentFragmentandDocument),DOMTokenList, an inlineCSSStyleDeclarationthatnormalizes values as jsdom's does and keeps the
styleattribute in step,DOMParser(a WHATWG tokenizer and the tree builder HTML import meets),the HTML fragment serializer, and one
documentper thread(
get_document). The property and entity tables are generated from thevectors by
rust/scripts/generate-dom-tables.mjs, as Swift's are.The core gets
utils/setDOMStyle.ts:getStyleObjectFromCSS(always,with JS's property order for array-index keys) and, with
html,setDOMStyleObjectandsetDOMStyleFromCSS.The conformance runner replays
html/parse,html/entities,css/propertiesandcss/values. Forcss/propertiesit checks thedeclaration's behavior with the same probes
css.test.tsasks jsdom, notonly the table; that showed that jsdom rejects a shadow of nothing but
identifiers (
box-shadow: Foo) and lower-cases CSS-wide keywords for everyproperty, which the declaration now does. Swift's declaration keeps such
shadows (its test compares only the table); #159 fixes that in Swift.
Test plan
Before
After
Before the shadow fix,
css/propertiesfailedbox-shadow,-webkit-box-shadowandtext-shadow(preserveCase: Rust true, JS false).