Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Example doesn't work correctly #1

Closed
rwaldron opened this Issue · 4 comments

2 participants

@rwaldron

Hi! Neat function.

The example looks for matchesSelector on document... needs to look on document.documentElement.

Also, check this out:

var matchesSelector = ["m","webkitM","mozM","msM","oM"].reduce(function(p, v) {
  return (document.documentElement[v + p] && v + p) || p;
}, "atchesSelector");


document.body[matchesSelector]("body"); // true
@ralt
Owner

Fixed. Thanks for pointing this out!

About the reduce function, it's not similar to the or: or stops looping as soon as possible. It's a mix between some and filter.

@ralt ralt closed this
@rwaldron

I agree, and I like the "stop iterating after the first truthy thing is found" semantics.

@rwaldron

Just wanted to thank you for this brief conversation. I was motivated to collect more use cases and I'm pleased to say that we accepted Array.prototype.find and Array.prototype.findIndex into the ES6 spec today. Notes will be published on Monday :)

@ralt
Owner

Yay! Glad to know I helped a little bit in making ES6 better :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.