-
Notifications
You must be signed in to change notification settings - Fork 1
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
#14 Fix placeholder #15
Conversation
return document.querySelector(value) || fallback; | ||
|
||
const element: ?HTMLElement = ([document.querySelector(value), ...fallbacks] | ||
.find(item => !!item && item instanceof HTMLElement): any); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀 Array.prototype.[filter|find]
type refinement problem workaround
facebook/flow#1414 (comment)
😭
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get the power of Typescript 🙄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ask
throw new Error('[Stuck.js] document.body is not HTMLElement in this environment'); | ||
set wrapper(value: SelectorOrElement): void { | ||
if (!(document.body instanceof HTMLElement)) { | ||
throw new TypeError('[Stuck.js] document.body is not HTMLElement in this environment'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 nice
@@ -1,11 +1,14 @@ | |||
/* @flow */ | |||
import Placeholder from './placeholder'; | |||
|
|||
type MaybeHTMLElement = HTMLElement|Element|null|void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does this include void
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Node.parentElement: ?Element;
https://github.com/facebook/flow/blob/v0.75.0/lib/dom.js#L439
that's why includes void
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
understood 👍
return document.querySelector(value) || fallback; | ||
|
||
const element: ?HTMLElement = ([document.querySelector(value), ...fallbacks] | ||
.find(item => !!item && item instanceof HTMLElement): any); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get the power of Typescript 🙄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks gooood 👍
this closes #14
Changes
Before
After