Skip to content

Commit

Permalink
fix: use html.isRaw method when appending child Markup instances (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
pgoldrbx authored Apr 16, 2018
1 parent 5d51cda commit 9d0c9e2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 3 additions & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

const isRaw = require('./html').isRaw;

const isArray = Array.isArray || function isArray(val) {
return val instanceof Array;
};
Expand Down Expand Up @@ -110,7 +112,7 @@ exports.appendChild = function appendChild(parent, child) {
// result was a JsonML node
parent.push(child);

} else if (exports.isRaw(child)) {
} else if (isRaw(child)) {

// result was a JsonML node
parent.push(child);
Expand Down
11 changes: 5 additions & 6 deletions test/utils.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const assert = require('assert');
const html = require('../lib/html');
const utils = require('../lib/utils');

describe('utils', function() {
Expand Down Expand Up @@ -311,18 +312,16 @@ describe('utils', function() {
});

describe('when appending a raw child', function() {
// @TODO - this will currently throw an error due to missing function `isRaw`
xit('should append to the parent', function() {
it('should append to the parent', function() {
const jml = ['div'];
const child = new function RawChild() {};
const child = html.raw('string value');
utils.appendChild(jml, child);
assert.strictEqual(jml, ['div', child]);
assert.deepEqual(jml, ['div', child]);
});
});

describe('when appending attributes', function() {
// @TODO - this will currently throw an error due to missing function `isRaw`
xit('should add attributes to the parent element', function() {
it('should add attributes to the parent element', function() {
const jml = ['div'];
const attrs = { a: 1 };
utils.appendChild(jml, attrs);
Expand Down

0 comments on commit 9d0c9e2

Please sign in to comment.