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

Uncaught error in Safari/iOS with HTML containing   #11

Open
jonpikum opened this issue Apr 28, 2016 · 0 comments
Open

Uncaught error in Safari/iOS with HTML containing   #11

jonpikum opened this issue Apr 28, 2016 · 0 comments

Comments

@jonpikum
Copy link

jonpikum commented Apr 28, 2016

When the DOM element is serialized, if the serialized string contains " ", the Image throws an onerror event. (that is swallowed)

I suppose this is more of a Safari bug.

However, the issue can be avoided by doing the following:

// serialize the DOM node to a String
var serialized = new XMLSerializer().serializeToString(elem);
serialized.replace(/ /gi, '');

or perhaps another more efficient solution. In my specific use case I don't care if the non-breaking-space ends up breaking, but I can see where this might be an issue for others

EDIT: The above code didn't work, had to do this...

// collect all nodes within the element, copy the current style to the clone
Array.prototype.forEach.call(children, function(child, i) {
     copyCSS(child, origChildren[i]);
     child.innerHTML = child.innerHTML.replace(/ /gi, '');
});
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

1 participant