Skip to content
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

Object created through Object.create(null) causes TypeError #176

Closed
sevlyar opened this issue Feb 1, 2018 · 0 comments
Closed

Object created through Object.create(null) causes TypeError #176

sevlyar opened this issue Feb 1, 2018 · 0 comments
Labels

Comments

@sevlyar
Copy link

sevlyar commented Feb 1, 2018

xmlbuilder version is 9.0.4

This code causes TypeError:

const xmlbuilder = require('xmlbuilder');
const plain = Object.create(null);
plain.field = 1;
xmlbuilder.begin().ele({ test: plain }).end();
TypeError: name.valueOf is not a function
    at XMLElement.module.exports.XMLNode.element (.../node_modules/xmlbuilder/lib/XMLNode.js:55:21)
    at XMLDocument.module.exports.XMLNode.element (.../node_modules/xmlbuilder/lib/XMLNode.js:85:23)
    at XMLDocument.module.exports.XMLNode.ele (.../node_modules/xmlbuilder/lib/XMLNode.js:357:19)

This is due to xmlbuilder uses .valueOf method but objects created through Object.create(null) don't have the method because they don't inherit Object.

@oozcitak oozcitak added the Bug label Feb 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants