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

TreeWalker #37

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

TreeWalker #37

wants to merge 3 commits into from

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?

@@ -102,7 +102,7 @@ export class Node extends EventTarget {
this._setOwnerDocument(newParent.#ownerDocument);

// 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?

@@ -9,7 +9,7 @@ export type Backend = "wasm" | "native";
export async function run(path: string, root: string, backend: Backend) {
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

@@ -39,7 +39,7 @@ export function test(backend: Backend) {
const limit = Infinity;
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;
}
}
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

@@ -289,7 +295,7 @@ export class Document extends Node {

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