forked from emberjs/ember.js
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ENV.EVENTED_FIRE flag to back port Ember.Evented#fire deprecation…
… warning. Also implemented Ember.Evented#trigger. Also replaced usage inside of Ember.State and Ember.View. Closes emberjs#8.
- Loading branch information
Showing
7 changed files
with
81 additions
and
10 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
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Ember.Evented#fire | ||
|
||
In Ember 1.0, `Ember.Evented#fire` has been deprecated. This fork introduces a flag, `ENV.EVENTED_FIRE`, with two allowed values: | ||
|
||
* `null` (the default) -- `Ember.Evented#fire` works per 0.9.8.1 | ||
* `"1.0"` -- Calling `Ember.Evented#fire` will trigger a deprecation warning | ||
|
||
In either case, `Ember.Evented#trigger` will work as per 1.0. | ||
|
||
See [issue #8](https://github.com/zendesk/ember.js/issues/8) for more information. |
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
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
function matches(msg, substr) { | ||
ok(msg.indexOf(substr) !== -1); | ||
} | ||
|
||
var originalFlag, originalWarn, warnings; | ||
|
||
module("Backported Ember.Evented#trigger", { | ||
setup: function() { | ||
originalFlag = Ember.ENV.EVENTED_FIRE; | ||
originalWarn = Ember.Logger.warn; | ||
warnings = []; | ||
Ember.Logger.warn = function(msg) { | ||
warnings.push(msg.replace("WARNING: ", "")); | ||
}; | ||
}, | ||
teardown: function() { | ||
Ember.ENV.EVENTED_FIRE = originalFlag; | ||
Ember.Logger.warn = originalWarn; | ||
} | ||
}); | ||
|
||
test("trigger works", function() { | ||
var obj = Ember.Object.createWithMixins(Ember.Evented), | ||
fooCalledWith; | ||
|
||
obj.on('foo', function() { | ||
fooCalledWith = [].slice.call(arguments); | ||
}); | ||
|
||
obj.trigger('foo', 'bar', 'baz'); | ||
|
||
deepEqual(fooCalledWith, ['bar', 'baz']); | ||
}); | ||
|
||
test("fire warns on 1.0 level", function() { | ||
Ember.ENV.EVENTED_FIRE = '1.0'; | ||
var obj = Ember.Object.createWithMixins(Ember.Evented); | ||
obj.fire('foo'); | ||
equal(warnings.length, 1); | ||
matches(warnings[0], "Ember.Evented#fire() has been deprecated in favor of trigger() for compatibility with jQuery. It will be removed in 1.0. Please update your code to call trigger() instead."); | ||
}); |
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
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
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