Skip to content

Using Alfa directly in a website/browser environment #1254

Answered by Jym77
TobiasG95 asked this question in Questions
Discussion options

You must be logged in to vote

Checking further (this is part of the code I'm not really using 😅 ), it seems that alfa-dom/Native.fromNode should do the trick to turn the node into an Alfa JSON that can be fed to Node.from

Does

import { Native, Node } from "@siteimprove/alfa-dom"

const alfaDocument = Node.from(Native.fromNode(window.document))

work?
(this is essentially what is done in Puppeteer.toNode with an extra trick around the JSHandle)

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
1 reply
@TobiasG95
Comment options

Comment options

You must be logged in to vote
4 replies
@TobiasG95
Comment options

@Jym77
Comment options

@TobiasG95
Comment options

@Jym77
Comment options

Answer selected by TobiasG95
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants