-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUGFIX beta] Ensure closure actions are wrapped in a run loop.
As discussed in Ember core team meeting on 2015-10-23.
- Loading branch information
Showing
2 changed files
with
32 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import { symbol } from 'ember-metal/utils'; | |
import { get } from 'ember-metal/property_get'; | ||
import { labelForSubexpr } from 'ember-htmlbars/hooks/subexpr'; | ||
import EmberError from 'ember-metal/error'; | ||
import run from 'ember-metal/run_loop'; | ||
|
||
export const INVOKE = symbol('INVOKE'); | ||
export const ACTION = symbol('ACTION'); | ||
|
@@ -70,25 +71,24 @@ function createClosureAction(target, action, valuePath, actionArguments) { | |
var closureAction; | ||
|
||
if (actionArguments.length > 0) { | ||
closureAction = function() { | ||
closureAction = function(...passedArguments) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
rwjblue
Author
Member
|
||
var args = actionArguments; | ||
if (arguments.length > 0) { | ||
var passedArguments = Array.prototype.slice.apply(arguments); | ||
if (passedArguments.length > 0) { | ||
args = actionArguments.concat(passedArguments); | ||
} | ||
if (valuePath && args.length > 0) { | ||
args[0] = get(args[0], valuePath); | ||
} | ||
return action.apply(target, args); | ||
|
||
return run.join(target, action, ...args); | ||
}; | ||
} else { | ||
closureAction = function() { | ||
var args = arguments; | ||
closureAction = function(...args) { | ||
if (valuePath && args.length > 0) { | ||
args = Array.prototype.slice.apply(args); | ||
args[0] = get(args[0], valuePath); | ||
} | ||
return action.apply(target, args); | ||
|
||
return run.join(target, action, ...args); | ||
}; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
why not just use
run.bind