You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importgetCssSelectorfrom'css-selector-generator';// raise "window is not undefined"
Then I try to import it form source instead from 'build/index.js'.
importgetCssSelectorfrom'css-selector-generator/src/index.js';// raise "document is not defined"
I use jsdom to provide a browser like environment. But I didn't expose the window or Document object to global context.
Is it possible to access these global variables by the element that passed to getCssSelector(). So there's less global variable dependencies (e.g: using elem.ownerDocument to access Document)
The text was updated successfully, but these errors were encountered:
When referencing root node, calls to `document` are replaced with calls
to `element.ownerDocument`. This is an attempt to make this library work
in environments with no global objects, e.g. jsdom.
refs #40
This is exactly why I hate virtual environments like jsdom. It's fine for testing simple React components. But it falls apart the moment you are trying to do anything more substantial with DOM. It's a Potemkin village.
@mika-cn I have tried to change the code so that it does not ask directly for document's root node, but for element.ownerDocument's root node. Hope it helps. Please update to v2.1.0 and let me know if it works for you.
Then I try to import it form source instead from 'build/index.js'.
I use jsdom to provide a browser like environment. But I didn't expose the window or Document object to global context.
Is it possible to access these global variables by the element that passed to
getCssSelector()
. So there's less global variable dependencies (e.g: usingelem.ownerDocument
to accessDocument
)The text was updated successfully, but these errors were encountered: