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

Implement declarative shadow DOM #568

Merged
merged 1 commit into from
Jan 13, 2025

Conversation

longvatrong111
Copy link
Contributor

@longvatrong111 longvatrong111 commented Jan 10, 2025

Implement declarative shadow dom (DSD) since it is necessary for several minor issues on Servo (for example: servo/servo#34746, servo/servo#34745)

Design doc (WIP):
Declarative Shadow DOM for Servo

This PR implements DSD creation.

Copy link
Contributor

@simonwuelker simonwuelker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good to me, with one minor suggestion

html5ever/src/tree_builder/mod.rs Outdated Show resolved Hide resolved
html5ever/src/tree_builder/mod.rs Outdated Show resolved Hide resolved
@simonwuelker simonwuelker added this pull request to the merge queue Jan 13, 2025
Merged via the queue into servo:main with commit 24df05e Jan 13, 2025
5 of 6 checks passed
// template start tag's shadowrootmode is not in the none state
let is_shadow_root_mode = tag.attrs.iter().any(|attr| {
attr.name.local == local_name!("shadowrootmode")
&& (attr.value.to_string() == String::from("open") || attr.value.to_string() == String::from("close"))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we compare attribute values without creating String objects (which requires memory allocation)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, we can avoid String creation in both sides like this:
attr.value.as_ref() == "open" || attr.value.as_ref() == "close"
I'll update with other missing parts of this feature.

@longvatrong111 longvatrong111 deleted the declarative-shadow-dom branch January 25, 2025 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants