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

Replacement of non strings #4

Closed
kartharer opened this issue Nov 24, 2012 · 2 comments
Closed

Replacement of non strings #4

kartharer opened this issue Nov 24, 2012 · 2 comments

Comments

@kartharer
Copy link

Thanks for this helpful code!

But in line 17 I had to say 'return String(txt).replace …' because of an runtime error with numbers.

And different from your samples I had to use {filter:…} always for the &.

@davidcalhoun
Copy link
Owner

(sorry for the delay - I've been on a sort of sabbatical)

Weird, I don't see this on my end, but it technically should be failing with numbers. I added your suggestion to coerse it into a String every time.

Looking into the other issue now.

Thanks for the feedback!

@davidcalhoun
Copy link
Owner

Not sure I see what you mean with the &. What environment are you running on?

I see this on my end:

jstoxml.toXML({
  foo: '&'
}
// Output: <foo>&</foo>
jstoxml.toXML({
  foo: '&'
},
{
  filter: {
    '&': '&amp;'
  }
}
// Output: <foo>&amp;</foo>

I added a few more tests based on your issue. Thanks!

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