Skip to content

Commit f58a931

Browse files
authored
Add notes about upcoming 1.0
1 parent abf1741 commit f58a931

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ Undom aims to find a sweet spot between size/performance and utility. The goal i
2323

2424
The intent to keep things as simple as possible means undom lacks some DOM features like HTML parsing & serialization, Web Components, etc. These features can be added through additional libraries.
2525

26+
#### Looking to 1.0.0
27+
28+
As of version 1.0.0, the DOM constructors and their prototypes will be shared for all instances of a document, as is the case with [JSDOM](https://github.com/jsdom/jsdom#shared-constructors-and-prototypes). Once merged, [PR #25](https://github.com/developit/undom/pull/25) will address this by adding an `undom.env()` function, which returns a fresh document factory with a new set of constructors & prototypes.
2629

2730
---
2831

@@ -77,10 +80,14 @@ One task `undom` doesn't handle for you by default is HTML serialization. A pro
7780
#### Small & in ES2015:
7881

7982
```js
80-
Element.prototype.toString = el => this.nodeType===3 ? enc(this.textContent) : (
81-
'<'+this.nodeName.toLowerCase() + this.attributes.map(attr).join('') + '>' +
82-
this.childNodes.map(serialize).join('') + '</'+this.nodeName.toLowerCase()+'>'
83-
);
83+
Element.prototype.toString = function() { return serialize(this); };
84+
85+
function serialize(el) {
86+
return el.nodeType==3 ? enc(el.data) : (
87+
'<'+this.nodeName.toLowerCase() + this.attributes.map(attr).join('') + '>' +
88+
this.childNodes.map(serialize).join('') + '</'+this.nodeName.toLowerCase()+'>'
89+
);
90+
}
8491
let attr = a => ` ${a.name}="${enc(a.value)}"`;
8592
let enc = s => s.replace(/[&'"<>]/g, a => `&#${a};`);
8693
```

0 commit comments

Comments
 (0)