Skip to content

Conversation

@0xAozora
Copy link

TreeWalker implementation for native,
The wpt/dom/traversal/TreeWalker unittest seems to be broken, it passes all other test.

I hope this helps.

@0xAozora 0xAozora changed the title Tree walker TreeWalker Apr 10, 2021
@b-fuze
Copy link
Owner

b-fuze commented Apr 10, 2021

Thanks for the PR. A few things:

The codebase style needs to be honored, so

  • only strict equality (===) except for == null to match null or undefined
  • always end lines with semi-colons
  • only double-quotes for strings
  • always 2 space indents
  • trailing commas
  • Typescript enum instead of abstract classes
  • spaces after control flow block keywords i.e. if (...) and while (...) instead of if(...), etc

I really need to setup deno fmt or smth already 😓

There are also parts that touch unrelated parts of the codebase; please submit a separate PR for those

@0xAozora
Copy link
Author

I did you the honor.

There are also parts that touch unrelated parts of the codebase; please submit a separate PR for those

Any idea how to outsource part of the commits to a separate branch?

Also, how did you run the wpt tests? I had to comment out the argument check since deno doesnt allow arguments when testing.

@b-fuze
Copy link
Owner

b-fuze commented Apr 10, 2021

Alright, thanks. Everything mostly looks fine, but I'll check it in more detail later today or tomorrow.

Any idea how to outsource part of the commits to a separate branch?

You can create a new branch with

git checkout -b new-branch-name

run git reflog to see the commit that you had to revert or whatever, then run

git reset --hard $COMMIT_HASH_FROM_REFLOG

then the new branch will have the contents of the commit you reverted.

Also, how did you run the wpt tests? I had to comment out the argument check since deno doesnt allow arguments when testing.

It's in the "Running tests" section of the readme:

Then append -- --wpt to the test command before running it, e.g. for WASM

deno test --allow-read wasm.test.ts -- --wpt

Copy link
Owner

@b-fuze b-fuze left a comment

Choose a reason for hiding this comment

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

Sorry, I was pretty busy. I noticed a few more things that need to be addressed before I can merge this

createComment(data?: string): Comment {
return new Comment(data);
}

Copy link
Owner

Choose a reason for hiding this comment

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

Why was this moved?


// Add parent chain to ancestors
let parent: Node | null = newParent;
const parent: Node | null = newParent;
Copy link
Owner

Choose a reason for hiding this comment

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

Please revert this whole file, it is unrelated to the PR. If you want to submit this, please do it as a separate PR.

let unitDir = join(dirname(new URL(import.meta.url).pathname), "units");
if (Deno.build.os === "windows") {
unitDir = unitDir.slice(1);
}
Copy link
Owner

Choose a reason for hiding this comment

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

What is this for?

const html = await Deno.readTextFile(path);
const doc = parser.parseFromString(html, "text/html")!;
let scripts = Array.from(doc.querySelectorAll("script")).map(scriptNode => {
const scripts = Array.from(doc.querySelectorAll("script")).map(scriptNode => {
Copy link
Owner

Choose a reason for hiding this comment

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

Please revert this file

let count = 0;

for (const testDir of [wptNodeTests]) {
for (const testDir of [wptTraversalTests, wptNodeTests]) {
Copy link
Owner

Choose a reason for hiding this comment

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

This is fine, but WPT tests don't really work atm. We'll need to write some separate basic tests for TreeWalker in test/units


export interface Filter {
acceptNode(node: Node): number;
}
Copy link
Owner

Choose a reason for hiding this comment

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

Please move this to treewalker.ts

this.activeFlag = false;
return result;
}
} No newline at end of file
Copy link
Owner

Choose a reason for hiding this comment

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

Please move this to treewalker.ts

export class HTMLDocument extends Document {
constructor() {
let lock = getLock();
const lock = getLock();
Copy link
Owner

Choose a reason for hiding this comment

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

Please revert this

@b-fuze
Copy link
Owner

b-fuze commented Apr 14, 2021

Btw, to revert a full file you can use

git checkout 813ce27 ./path/to/file.ts

@chances
Copy link

chances commented Aug 9, 2024

@b-fuze Any chance you could apply your suggestions to this branch yourself and get this merged?

If not, if the staleness of these changes are an issue, I can fork this branch and open a fresh PR.

@b-fuze
Copy link
Owner

b-fuze commented Aug 12, 2024

@chances unfortunately, no. The contributor themselves has to give me access to modify the PR. I'll probably close this and implement it myself at some point.

@0xAozora
Copy link
Author

@b-fuze Access granted

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