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

Fix errors caused by mutations on certain elements #2

Closed
wants to merge 1 commit into from

Conversation

tpett
Copy link

@tpett tpett commented Jan 24, 2023

In my use case, we are having to modify the d attribute on a path element inside of an svg tag. This is triggering the MutationObserver. However, the Node object returned by the path element in javascript is not compatible with the expectations in this observer. It still has a className property, but it is not a string type but a SVGAnimatedString. This SVGAnimatedString type does not have an includes property causing these calls to error out.

While it may not be the most elegant fix, adding in a check to see if the includes property is defined fixes this error in my specific use case.

In my use case, we are having to modify the `d` attribute on a `path` element inside of an `svg` tag. This is triggering the MutationObserver. However, the `Node` object returned by the `path` element in javascript is not compatible with the expectations in this observer. It still has a `className` property, but it is not a string type but a `SVGAnimatedString`. This `SVGAnimatedString` type does not have an `includes` property causing these calls to error out.

While it may not be the most elegant fix, adding in a check to see if the includes property is defined fixes this error in my specific use case.
@volkandkaya volkandkaya closed this Jul 6, 2023
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

Successfully merging this pull request may close these issues.

2 participants