Comments (16)
This seems to pass the @jdalton test: http://jsfiddle.net/QF9ZA/2/
from mootools-core.
Note that there are three different cases:
1.3 without native bind: fix this one
1.3 with native bind: √
1.2compat: ignore this
from mootools-core.
This should fix 1.3 without compat or native bind: arian@5c1df58c0d0
from mootools-core.
In new browsers this changes slows down bind significantly. In IE8 (about 10%) and 7 the difference is less, but still slower (of course) http://jsperf.com/function-proto-bind
from mootools-core.
I think there is probably room to tweak a bit, but the speed diff doesn't concern me much. Doing things right could come at a cost and it makes sense now that native
is faster than the updated fallback
.
from mootools-core.
Agreed, and thanks to Arian's clarification 1.3 runs native if present and for 1.2 with compat runs a much slower version :(. Nevertheless, I guess the bench should compare against non native bind. Finally, agreed that there's only too much one can do to speed this up.
from mootools-core.
I'm cool with this. We should only fix 1.3 (1.2compat is non-standard anyway) and only few browsers don't have bind natively, so we should be fine :) Pull Request !
from mootools-core.
Oh man, Safari still doesn't have bind :o
from mootools-core.
Also, we can probably use
(this && this != window)
as an adequate check.
@jdalton - what do you think?
from mootools-core.
a check for this != window
means it breaks in a headless environment.
from mootools-core.
What about arian@b38e69f886
from mootools-core.
@cpojer this
could be none-window a lot of the time so that wouldn't do:
For example:
foo.bar = baz.bar.bind(baz, 'x', 'y');
Also ya'll could take it up a notch and implement a custom call/apply method too (I'll update my list to include that). By spec bound.call(thisArg, 'z')
should ignore thisArg
and curry args as if called like bound('z')
.
from mootools-core.
@jdalton: that should already work: http://jsfiddle.net/arian/QF9ZA/6/
var other = function(){
console.log(this.foo, arguments);
};
other.bind({foo: 'bar'})(); // → bar
other.bind({foo: 'bar'}, 'first').call({foo: 'yeah!'}, 'yooo'); // → bar, ['first', 'yeah!']
from mootools-core.
@arian except if you call/apply with an instance of the bound function as the thisArg
. It shouldn't be treated as new bound
.
from mootools-core.
So am I missing something? https://gist.github.com/1124879
from mootools-core.
@arian add a test for .apply()
too
from mootools-core.
Related Issues (20)
- Request/Request.HTML execute non-javascript <script> tags as Javascript HOT 1
- Update Array.prototype.flatten to match TC39 proposal HOT 13
- Deprecate MooTools? HOT 9
- creating 404 error for video preroll ad on adding just library. HOT 8
- Change this repo title to HTTPS HOT 7
- Conflict with ecmascript Map HOT 2
- Mootools + Google Maps V3 conflict issue causing google streetview not working. HOT 9
- Object.merge deletes EcmaScript Map Object HOT 4
- MooTools library conflicting with new Event(typeArg) HOT 3
- NS_ERROR_FAILURE XMLHttpRequest exception HOT 9
- Mootools.net down HOT 8
- [spam]
- [SPAM]
- Mootools + Google adsense
- GHSL-2020-345: seeking security contact for your project
- Digital Marketing Course
- spam
- node modules error HOT 3
- mootools.net down HOT 2
- Joomla 3. Recaptcha v2 always spin. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mootools-core.