Closed bnjmnt4n closed 10 years ago
I used the has("...")
form for compatibility with has.js
-aware optimizers, like RequireJS. The optimization tool will replace the has
call with a Boolean primitive, and unnecessary branches (along with the has
function) can then be removed during minification. I think this pull request would break that behavior, though—this is why the has
function is self-contained. +@unscriptable @jaredcacurak
I could store the test results as properties on the has
function itself, though—that shouldn't interfere with Uglify's or Closure Compiler's dead code removal. I remember that the has
function wouldn't be removed if I stored the test results in closed-over outer variables; this may no longer be the case. I'll have a look.
Thanks anyway, I might just rewrite the tests to cache the results on has when I'm free.
Yah, I don't like that the has(id) syntax requires strings in the code. Seems so primitive. Anybody want to write a has2.js? ;)
Will close this for now and open new PR
Now at #41
I've switched has to an IIFE returning an object with support info. This prevents tests from being repeated as well, ie.
repeats the json stringify and parse support tests twice each.