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

bug: this keyword in constructSubtreeForNode makes error #13

Closed
ghost opened this issue Jun 29, 2020 · 4 comments
Closed

bug: this keyword in constructSubtreeForNode makes error #13

ghost opened this issue Jun 29, 2020 · 4 comments

Comments

@ghost
Copy link

ghost commented Jun 29, 2020

When I import module like this:
const {constructSubtreeForNode, constructShadowTree} = require("./subtree");

this keyword makes error at this point:

const shadowTree = this.constructShadowTree(document, nodeLike, includeIframes, domErrorOutput, nodeLike.shadowRoots[0]);

I wanna talk about how can we fix this :)

@ghost ghost mentioned this issue Jun 29, 2020
@AVGP
Copy link
Collaborator

AVGP commented Jun 30, 2020

Hey @TroyTae - thank you so much for your contribution and welcome to the project!

I would suggest to use the module as a whole when testing it, like this:

const subtree = require('./subtree');

test("shadow root", () => {
  const nodeName = "DIV";
  const subTree = constructSubtreeForNode(document, {
    nodeType: NODE_TYPES.ELEMENT_NODE,
    nodeName: nodeName,
    children: [createElemForNode(document, 'all', {
      nodeType: NODE_TYPES.ELEMENT_NODE,
      nodeName: nodeName
    })],
    shadowRoots: [createElemForNode(document, 'all', {
      nodeType: NODE_TYPES.ELEMENT_NODE,
      nodeName: nodeName
    })]
  });
});

@AVGP
Copy link
Collaborator

AVGP commented Jun 30, 2020

I think that solves the problem, should I be wrong, please reopen the issue and let me know :)

@AVGP AVGP closed this as completed Jun 30, 2020
@ghost
Copy link
Author

ghost commented Jun 30, 2020

Yes of course the code can fix problem.
I’m just worried about guide to not use object split to developer.
But maybe it’s fine because this is experimental project yet :)

@AVGP
Copy link
Collaborator

AVGP commented Jun 30, 2020

I understand that point, but subtree is an internal part of dom2html and is neither documented nor should it be used, normally. The usual entrypoint is serialize.

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

No branches or pull requests

1 participant