ReferenceError: Element is not defined - nodejs-pal
dweber019 opened this issue ยท 6 comments
I'm submitting a bug report
- Library Version:
1.6.2 / 2.0.0
Please tell us about your environment:
-
Operating System:
OSX -
Node Version:
6.11.4 -
NPM Version:
3.10.10 -
JSPM OR Webpack AND Version
webpack 3.8.1 -
Browser:
Jest -
Language:
TypeScript 2.6.1
Setup:
I'm using a slighly changed version of the Aurelia Skeleton for Webpack and Typescript.
There I have tests, which mock i18n => https://github.com/w3tecch/aurelia-typescript-boilerplate/blob/feature/dependency-update/test/unit/app.spec.ts#L50
I have now upgraded to the latest dependencies regarding Aurelia and everything from building to running the app in the browser (even e2e test) work fine.
Sadly the jest unit tests are broken with the following errror:
ReferenceError: Element is not defined
at Object.<anonymous> (node_modules/aurelia-i18n/dist/commonjs/t.js:59:24)
at Object.<anonymous> (node_modules/aurelia-i18n/dist/commonjs/aurelia-i18n.js:34:10)
at Object.<anonymous> (src/app.spec.ts:2:16)
This error disappears when I remove aurelia-i18n.
There is no difference in using version 1.6.2 or 2.0.0. So I think it has something to do with the other Aurelia dependencies, which are the lastest as of today.
The tests in aurelia-i18n repository are using aurelia-pal-browser
. On the other hand the Aurelia-CLI and the Aurelia Skeleton are using the aurelia-pal-nodejs
and so do I. Maybe this makes some difference regarding this issue.
If you like to reproduce checkout this branch, yarn install and run npm test:
https://github.com/w3tecch/aurelia-typescript-boilerplate/tree/feature/dependency-update
Thanks for any advise / help
@dweber019 let me first say thanks for the great issue report and the example to reproduce the issue. This makes fixing things much easier :)
So the reason was that the i18n plugin still directly referenced window
instead PLATFORM.global
and injected the Element
instead of DOM.Element
provided by the specific PAL.
I've checked out your example and with these fixes it works. With the next release everything should be ok. Thanks again for the feedback
@zewa666 awesome! Really like you guys speed on fixing things.
Do you have any estimate on when this fix will be published?
I've already contacted @EisenbergEffect and queued this up for the next release cycle. So as soon as his time permits this will be pushed. In the meantime if this is a blocker for you, you can fork the repo, build the dist files and reference your fork for the time being.
@EisenbergEffect, @zewa666 i think this kind of problems could be automatically detected with aurelia-template-lint - it just needs small improvements (additional rule, that would alert via linter when using globals, that don't work with aurelia-pal-nodejs)
@dweber019 please check out the latest release, closing this for now. if there are any issues please report back.
Thanks a lot. Amazing speed ๐