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(typeahead): Fix crash on Firefox and contenteditable input #2057

Conversation

adrienverge
Copy link
Contributor

When using the typeahead directive on a contenteditable input, crashes can happen on Firefox:

TypeError
n.target.innerText is undefined

According to many sources [1] [2] [3], innerText should only be used on old browsers where textContent in not defined (e.g. Internet Explorer). On newer browsers that abide by standards, textContent is the right property to use to avoid problems.

[1]: https://stackoverflow.com/a/22990890
[2]: https://teamtreehouse.com/community/firefox-innertext-undefined-teachers-note
[3]: https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent

@codecov
Copy link

codecov bot commented Jun 13, 2017

Codecov Report

Merging #2057 into development will decrease coverage by 0.03%.
The diff coverage is 0%.

Impacted file tree graph

@@               Coverage Diff               @@
##           development    #2057      +/-   ##
===============================================
- Coverage        87.13%   87.09%   -0.04%     
===============================================
  Files               85       85              
  Lines             2262     2263       +1     
  Branches           292      293       +1     
===============================================
  Hits              1971     1971              
- Misses             188      189       +1     
  Partials           103      103
Impacted Files Coverage Δ
src/typeahead/typeahead.directive.ts 75.84% <0%> (-0.43%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 325b510...bd9a13d. Read the comment docs.

When using the typeahead directive on a `contenteditable` input, crashes
can happen on Firefox:

    TypeError
    n.target.innerText is undefined

According to many sources [1] [2] [3], `innerText` should only be used
on old browsers where `textContent` in not defined (e.g. Internet
Explorer). On newer browsers that abide by standards, `textContent` is
the right property to use to avoid problems.

[1]: https://stackoverflow.com/a/22990890
[2]: https://teamtreehouse.com/community/firefox-innertext-undefined-teachers-note
[3]: https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent
@adrienverge adrienverge force-pushed the fix/typeahead/typeerror-on-firefox branch from 6e6e703 to bd9a13d Compare June 24, 2017 07:48
@adrienverge
Copy link
Contributor Author

@valorkin I rebased on latest development!

@valorkin valorkin merged commit 8656326 into valor-software:development Jul 18, 2017
@valorkin
Copy link
Member

Thanks for PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants