Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #52 by using
lookupNamespaceURI
and supporting changes.Tested with current Chromium (89) and Firefox (86) on Ubuntu (not on IE or other browsers).
See updated demo that now has the
locus:
prefix in the XML string also.Failing tests are in separate commits before fixes, so they can be checked out and seen failing (feel free to squash).
Includes the following changes:
createElement
and namespace retrieval code into functionslookupNamespaceURI
.appendChild
is now done before recursing down (plugging together top down instead of bottom up).xmlns
attributes handled automatically withcreateElementNS
doesn't seem to work for all cases. So they are added explicitly now withsetAttributeNS
and their namespacehttp://www.w3.org/2000/xmlns/
, which is needed for lookup. This way, they can be set anywhere in the parent hierarchy of a prefixed element.stringToJs
->jsToString
, as the the namespace lookup needs thexmlns
attributes to already exist in the document.Resources