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

Prevent infinite loop when title attribute is changed #131

Merged
merged 1 commit into from
Nov 20, 2019
Merged

Conversation

dmarcey
Copy link
Contributor

@dmarcey dmarcey commented Nov 19, 2019

Fixes #130

I tried adding a test case here to use a MutationObserver to ensure that we weren't continuously calling the callback, but I couldn't get it to work.

If anyone has any suggestions on a good way to write a test, let me know!

Copy link
Member

@keithamus keithamus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this and providing a fix @dmarcey!

Are we able to write a test that changes the attribute title and ensures that there's no stack overflow? Perhaps try/catching a setAttribute call?

@muan thoughts?

@dmarcey
Copy link
Contributor Author

dmarcey commented Nov 19, 2019

I tried a test like this:

test('title change does not throw RangeError', function() {
  const time = document.createElement('local-time')

  try {
    time.setAttribute('title', 'custom title')
  } catch (e) {
    assert.fail(`Error thrown: ${e.message}`)
  }
})

and it didn't fail without my change, unfortunately

Copy link
Contributor

@muan muan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching and fixing this.

@keithamus Looks like the error is just not reported? The error shows up when I run the test in browser mode, but the tests pass regardless.

@dmarcey
Copy link
Contributor Author

dmarcey commented Nov 19, 2019

@muan should I bump the package version to 3.0.10?

@muan
Copy link
Contributor

muan commented Nov 19, 2019

We can do that after this is merged.

@muan muan merged commit 925b952 into master Nov 20, 2019
@muan muan deleted the title-loop branch November 20, 2019 15:58
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.

"Maximum call stack size exceeded error" with 3.0.9
3 participants