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

Fail to insert an empty string attribute #18

Open
foxever opened this issue Jul 16, 2015 · 1 comment
Open

Fail to insert an empty string attribute #18

foxever opened this issue Jul 16, 2015 · 1 comment

Comments

@foxever
Copy link

foxever commented Jul 16, 2015

isFalse('') returns true do nothing, testing with Node.js 0.10.40.

function isFalse(s) {
  return typeof s !== 'number' && !s;
}

writeAttribute : function (name, content) {
    if (typeof content == 'function') {
      content = content();
    }
    if (isFalse(content)) {
       return this;
    }
    return this.startAttribute(name).text(content).endAttribute();
}
@vijaybhas
Copy link

i am also having the similar issue:
we can modify it as

writeAttribute : function (name, content) {
    if (typeof content == 'function') {
      content = content();
    }    
    return this.startAttribute(name).text(content).endAttribute();
}

or it can configurable whether to write empty string or not adding the attribute.
perhaps we might need empty string for schema validation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants