Skip to content

Fix properties classified as nodes #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function isNode(tagName, value) {
)
}

return 'value' in value
return false
}

function addChild(nodes, value) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"xo": "^0.23.0"
},
"scripts": {
"format": "remark . -qfo && prettier --write '**/*.js' && xo --fix",
"format": "remark . -qfo && prettier --write \"**/*.js\" && xo --fix",
"build-bundle": "browserify . -s hastscript > hastscript.js",
"build-mangle": "browserify . -s hastscript -p tinyify > hastscript.min.js",
"build": "npm run build-bundle && npm run build-mangle",
Expand Down
11 changes: 11 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,17 @@ test('hastscript', function(t) {
'should allow passing multiple child nodes as arguments when there is no properties argument present'
)

t.deepEqual(
h('div', {type: 'test', value: 'value'}),
{
type: 'element',
tagName: 'div',
properties: {type: 'test', value: 'value'},
children: []
},
'should *not* interpret an attribute as children when it has an attribute called "value"'
)

st.throws(
function() {
h('foo', {}, true)
Expand Down