sanctuary-js / sanctuary-def

Run-time type system for JavaScript
MIT License
294 stars 23 forks source link

types: fix HtmlElement predicate #311

Closed davidchambers closed 2 years ago

davidchambers commented 2 years ago

Fixes #309

> Object.prototype.toString.call (document.createElement ('div'))
'[object HTMLDivElement]'

> Object.prototype.toString.call (document.createElement ('section'))
'[object HTMLElement]'

Before:

> /^\[object HTML.+Element\]$/.test (Object.prototype.toString.call (document.createElement ('section')))
false

After:

> /^\[object HTML.*Element\]$/.test (Object.prototype.toString.call (document.createElement ('section')))
true

/cc @dotnetCarpenter

dotnetCarpenter commented 2 years ago

@davidchambers 👍

I've tested your change in Firefox and it works! But I am puzzled to how I got ... aha I see. I used Object.toString; and not Object.prototype.toString;.

You're fix is great :)