Skip to content

Commit

Permalink
fix(dom): add NodeList to global
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Taran committed Feb 25, 2018
1 parent 394da3e commit 20ce260
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion spec/nodejs-dom.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { initialize } from '../src/index';
import { DOM } from 'aurelia-pal';
import { DOM, PLATFORM } from 'aurelia-pal';
import { JSDOM } from 'jsdom';

initialize();
Expand Down Expand Up @@ -100,4 +100,9 @@ describe('NodeJs Dom', () => {
it('dispatchEvent is defined', () => {
expect(DOM.dispatchEvent).toBeDefined();
});

it('NodeList is defined',()=>{
expect(PLATFORM.global.NodeList).toBeDefined();
});

});
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export function globalize() {
global.window = global.self = PLATFORM.global;
global.document = PLATFORM.global.document;
global.Element = DOM.Element;
global.NodeList = PLATFORM.global.NodeList;
global.SVGElement = DOM.SVGElement;
global.HTMLElement = PLATFORM.global.HTMLElement;
global.requestAnimationFrame = PLATFORM.global.requestAnimationFrame;
Expand Down
2 changes: 2 additions & 0 deletions src/nodejs-dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ export class NodeJsDom implements IDom {

constructor(public global: IGlobal) {
this.Element = global.Element;
this.NodeList = global.NodeList;
this.SVGElement = global.SVGElement || class SVGElement extends global.Element { };
}

Element: typeof Element;
NodeList: typeof NodeList;
SVGElement: typeof SVGElement /* until a proper implementation is ready: */ | any;
boundary: string = 'aurelia-dom-boundary';
title: string = "";
Expand Down
1 change: 1 addition & 0 deletions src/nodejs-global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ declare namespace NodeJS {
self: typeof window;
document: typeof Window.prototype.document;
Element: typeof Element;
NodeList: typeof NodeList;
SVGElement: typeof SVGElement;
HTMLElement: typeof HTMLElement;
requestAnimationFrame: typeof requestAnimationFrame;
Expand Down

0 comments on commit 20ce260

Please sign in to comment.