-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
91 additions
and
4 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
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,27 @@ | ||
import Ember from 'ember'; | ||
import { module, test } from 'qunit'; | ||
|
||
module('Ember.K'); | ||
|
||
test('that Ember.K is correctly polyfilled', assert => { | ||
assert.equal(typeof Ember.K, 'function', 'function is defined on Ember'); | ||
}); | ||
|
||
test('that Ember.K properly returns this when invoked', function(assert) { | ||
let Thing = Ember.Object.extend({ | ||
randomMethod: Ember.K, | ||
}); | ||
|
||
let instance = Thing.create(); | ||
assert.strictEqual(instance.randomMethod(), instance, 'Ember.K returns this'); | ||
}); | ||
|
||
test('that Ember.K is deprecated', function(assert) { | ||
assert.expectDeprecation(() => { | ||
let obj = { | ||
noop: Ember.K | ||
}; | ||
|
||
assert.equal(obj, obj.noop()); | ||
}, 'Ember.K is deprecated in favor of defining a function inline.'); | ||
}); |
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,42 @@ | ||
(function() { | ||
var _Ember; | ||
if (typeof Ember !== 'undefined') { | ||
_Ember = Ember; | ||
} else { | ||
_Ember = require('ember').default; | ||
} | ||
|
||
if (EmberENV && EmberENV._ENABLE_EMBER_K_SUPPORT !== true) { | ||
return false; | ||
} | ||
|
||
if (_Ember.hasOwnProperty('K')) { | ||
return false; | ||
} | ||
|
||
/** | ||
An empty function useful for some operations. Always returns `this`. | ||
@method K | ||
@return {Object} | ||
@public | ||
@deprecated | ||
*/ | ||
function deprecatedEmberK() { return this; } | ||
|
||
Object.defineProperty(_Ember, 'K', { | ||
get() { | ||
_Ember.deprecate( | ||
'Ember.K is deprecated in favor of defining a function inline.', | ||
false, | ||
{ | ||
id: 'ember-metal.ember-k', | ||
until: '3.0.0', | ||
url: 'https://emberjs.com/deprecations/v2.x#toc_code-ember-k-code' | ||
} | ||
); | ||
|
||
return deprecatedEmberK; | ||
} | ||
}); | ||
})(); |
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