Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Throw an error when document.activeElement was null #332

Closed
hidekatsu-izuno opened this issue Aug 2, 2018 · 1 comment · Fixed by #333
Closed

Throw an error when document.activeElement was null #332

hidekatsu-izuno opened this issue Aug 2, 2018 · 1 comment · Fixed by #333

Comments

@hidekatsu-izuno
Copy link

I use both sapper and bable in combination for the compatibilty.
Then I saw the error that be unable to get property 'blur' of undefined or null reference.

document.activeElement.blur();`

This problem may only occur on IE. (I tested on IE11). When any elements are not focused, document.activeElement return document.body on the other browser. But there is a posibility that a element will be null or non element on IE.

So, it may have to rewrite the below a code.

try {
    document.activeElement.blur();
} catch (e) {
    document.body.blur()
}
@Rich-Harris
Copy link
Member

thanks! this is fixed in 0.15.5

mrkishi pushed a commit to mrkishi/sapper that referenced this issue Sep 21, 2018
only blur activeElement if there is one
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants