Skip to content

Commit

Permalink
Merge branch 'pull/26' (developit#26) into perf-adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewiggins committed Nov 1, 2020
2 parents e425075 + d38d1b9 commit 4772a14
Showing 1 changed file with 32 additions and 18 deletions.
50 changes: 32 additions & 18 deletions src/undom.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,32 @@ function createEnvironment() {
}


class Event {
constructor(type, opts) {
this.type = type;
this.bubbles = !!(opts && opts.bubbles);
this.cancelable = !!(opts && opts.cancelable);
}
stopPropagation() {
this._stop = true;
}
stopImmediatePropagation() {
this._end = this._stop = true;
}
preventDefault() {
this.defaultPrevented = true;
}
}


class Document extends Element {
constructor() {
super(9, '#document'); // DOCUMENT_NODE
this.defaultView = new DefaultView(this);
}

get document() {
return this;
}

createElement(type) {
Expand All @@ -167,37 +190,28 @@ function createEnvironment() {
return element;
}


createTextNode(text) {
return new Text(text);
}
}

assign(Document.prototype, { Document, Node, Text, Element, SVGElement: Element, Event });

class Event {
constructor(type, opts) {
this.type = type;
this.bubbles = !!(opts && opts.bubbles);
this.cancelable = !!(opts && opts.cancelable);
}
stopPropagation() {
this._stop = true;
}
stopImmediatePropagation() {
this._end = this._stop = true;
}
preventDefault() {
this.defaultPrevented = true;

class DefaultView {
constructor(document) {
this.document = document;
}
}

assign(DefaultView.prototype, { Document, Node, Text, Element, SVGElement: Element, Event });


/** Create a minimally viable DOM Document
* @returns {Document} document
*/
* @returns {Document} document
*/
function createDocument() {
let document = new Document();
assign(document, document.defaultView = { document, Document, Node, Text, Element, SVGElement: Element, Event });
document.appendChild(
document.documentElement = document.createElement('html')
);
Expand Down

0 comments on commit 4772a14

Please sign in to comment.