Skip to content

Commit

Permalink
Update jsdom to v16 (#20)
Browse files Browse the repository at this point in the history
Used in the DOM interface for using JsonML to interact with the DOM
and impacts functionality within a node runtime environment.

Update the html.patch method to prevent raising an error on text nodes.
Prior to updating jsdom, the node was not updated but no error was emitted.
  • Loading branch information
pgoldrbx authored Mar 6, 2020
1 parent c0e907b commit 0a9fc05
Show file tree
Hide file tree
Showing 7 changed files with 393 additions and 152 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Ensure valid table structure when creating or updating elements when
using the `toHTML()` or `patch()` methods ([#28])

### Changed
- Update jsdom to v16, used in the DOM interface for using JsonML to interact with the DOM.


[#28]: https://github.com/CondeNast/jsonml.js/pull/28

### Chores
Expand Down
4 changes: 2 additions & 2 deletions lib/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

'use strict';

const jsdom = require('jsdom').jsdom;
const { JSDOM } = require('jsdom');

/**
* A JsonML node represented as an Array or string value
Expand Down Expand Up @@ -206,7 +206,7 @@ var fromHTML = exports.fromHTML = function(elem, filter) {
};

const doc = typeof document === 'undefined' ?
jsdom(undefined, {}) :
(new JSDOM()).window.document :
document;

/**
Expand Down
4 changes: 4 additions & 0 deletions lib/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,10 @@ exports.onerror = null;
* @return {Node} DOM Node
*/
var patch = exports.patch = function(elem, jml, filter) {
// Cannot patch text nodes
if (elem.nodeType === 3) {
return elem;
}

for (var i=1; i<jml.length; i++) {
if (isArray(jml[i]) || 'string' === typeof jml[i]) {
Expand Down
Loading

0 comments on commit 0a9fc05

Please sign in to comment.