-
Notifications
You must be signed in to change notification settings - Fork 103
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
Problem processing the following html #127
Comments
Please provide a fullexample using jsfiddle or similar.
…On Mon, Aug 28, 2023, 18:21 Adrian Belmans ***@***.***> wrote:
When I calculate the diff using the following code snippets I run into
some trouble, for some reason multiline strings are not handled
accordingly. I first calculate the diff and then apply the diff on an empty
div.
when I use
<div data-interchange="[/some/link, (default)],
[/some/other/link, (medium)]">
</div>
I get the error
DOMException: Failed to execute 'setAttribute' on 'Element': '(default)],'
is not a valid attribute name. and when I use
<div data-interchange="
[/some/link, (default)],
[/some/other/link, (medium)]">
</div>
I get
DOMException: Failed to execute 'setAttribute' on 'Element': '[' is not a
valid attribute name.
but when I use
<div data-interchange="[/some/link, (default)], [/some/other/link, (medium)]">
</div>
then I get no error.
—
Reply to this email directly, view it on GitHub
<#127>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAERMOBEY2L7TZJFGHQU4ZTXXTAR3ANCNFSM6AAAAAA4BVA3TE>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Here is an example using JSfiddle, as you can see the diff contains invalid actions, more specifically you can see how it detects [ as an attribute which later on causes the previously mentioned error:
|
I found some other code that doesn't get diffed correctly;
I'll make a jsFiddle tomorrow as its pretty late |
Hey @nexon33 , |
If I diff on documentbody.body then (assuming the style tag is inside the body) i still get the same problem. I really like the library and think its awesome. I'd help with the library if I could and in fact might look into actually doing that. |
@nexon33 You mean In general, the HTML parsing issues have all been fixable until now, so this one is probably as well. It's a matter of spending the time needed on that. I am currently very busy with conferences, etc., so if you can work on it, that would be very much appreciated! |
Recently I encountered an error similar to this: Environment
BehaviourI have two strings and I want to compare them using the following code: dd = new diffDOM.DiffDOM()
const elementA = document.createElement('div');
const elementB = document.createElement('div');
// The following strings are returned from the API, suppose you can't control this
elementA.innerHTML = `<span>Random text</span>`;
elementB.innerHTML = `<ul><li><span data-random-attr='{"event":"mom\'s birthday"}'>Random text</span></li></ul>`; After creating a diff ( Finally, after applying the diff (
So, The error happens because the node created in the A partial solution could be to sanitize the strings using dompurify and the error will disappear Maybe this can help someone |
When I calculate the diff using the following code snippets I run into some trouble, for some reason multiline strings are not handled accordingly. I first calculate the diff and then apply the diff on an empty div.
when I use
I get the error
I get
but when I use
then I get no error.
The text was updated successfully, but these errors were encountered: