Skip to content

Conversation

@rnons
Copy link
Contributor

@rnons rnons commented Dec 17, 2019

Close #10

A reproducible (on Chrome) example is here https://codepen.io/rnons/pen/gObLQzY?editors=1011

<!-- index.html -->
<iframe></iframe>
<script>
const iframe = document.querySelector('iframe')
  iframe.contentWindow.addEventListener('click', ev => {
    console.log(ev.constructor.name)
    console.log(ev instanceof window.MouseEvent) // false!
  })
</script>

@garyb
Copy link
Member

garyb commented Dec 10, 2020

Maybe we could keep the early exit in the case of a positive result, but remove the early exit in the negative - the instanceof check should generally be faster than having to traverse the prototype chain.

if (ty != null && value instanceof ty) {
return just(value);
}
return nothing;
Copy link
Contributor

Choose a reason for hiding this comment

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

@garyb Do you mean simply removing this line, so that we return early in case of a positive result, but fall through otherwise?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, exactly.

@thomashoneyman thomashoneyman merged commit 9eee643 into purescript-web:master Dec 18, 2020
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.

_unsafeReadProtoTagged should not rely on window

3 participants