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

Next Dom document implementation #118

Merged
merged 13 commits into from
Dec 8, 2023
Merged

Next Dom document implementation #118

merged 13 commits into from
Dec 8, 2023

Conversation

krichprollsch
Copy link
Member

@krichprollsch krichprollsch commented Dec 7, 2023

  • createText
  • createCDATASection
  • createComment
  • createProcessingInstruction
  • importNode
  • adoptNode
  • createAttribute
  • createAttributeNS

Relates to #18
fix #26

@krichprollsch krichprollsch self-assigned this Dec 7, 2023
@krichprollsch krichprollsch changed the title Dom doc Next Dom document implementation Dec 7, 2023
src/dom/character_data.zig Outdated Show resolved Hide resolved
src/dom/node.zig Show resolved Hide resolved
@@ -226,6 +261,44 @@ pub fn testExecFn(
};
try checkCases(js_env, &createDocumentFragment);

var createTextNode = [_]Case{
.{ .src = "document.createTextNode('foo')", .ex = "[object Text]" },
Copy link
Member

Choose a reason for hiding this comment

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

Maybe it will be better to use the nodeName getter for the equality (here #text) rater than the string representation.

I see that the console of Chrome and Firefox returns different values here: just the value of the text itself (ie. foo) for Chrome and the concatenation of the nodeName and the text for Firefox (#text "foo").
But when you call the toString function you have [object Text] so I guess it's only the console of the dev tools who change the result printed to help web developers with a more explicit return.

So I guess the object string representation [object Text] is OK for equality at the JS VM level, but the nodeName could be better (but more verbose). Sincerly I'm not sure. WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

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

I wasn't really happy with this string representation, I'm ok to use nodeName instead 👍

Copy link
Member

Choose a reason for hiding this comment

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

You can also do it in 1 line document.createTextNode('foo').nodeName but I'm OK with this version

@krichprollsch krichprollsch merged commit dd74dbb into main Dec 8, 2023
4 checks passed
@krichprollsch krichprollsch deleted the dom-doc branch December 8, 2023 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CDATASection properties and methods
2 participants