-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use isComputed when available (#966)
* Attempt to use isComputed * Fix some failures * Point ember-table back at Addepar * Use correct path to isComputed * Pass object and key into isComputed and inspectValue * Get value from object * Update to ember canary * Point to commit for ember-table * Use object[key] rather than get(object, key) * Allow passing already computedValue * Fix error with removing listener * Add hacks to check for computed * Fix remaining failures * Set back to stable Ember version, disallow beta failures * Allow beta failures again * Fix lint * Run normal tests before ember-try
- Loading branch information
1 parent
2237dc1
commit aede612
Showing
11 changed files
with
533 additions
and
589 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
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,37 @@ | ||
const Ember = window.Ember; | ||
const { ComputedProperty } = Ember; | ||
|
||
/** | ||
* Check if given key on the passed object is a computed property | ||
* @param object | ||
* @param key | ||
* @return {boolean|*} | ||
*/ | ||
export function isComputed(object, key) { | ||
// Ember > 3.10 | ||
if (Ember.Debug.isComputed) { | ||
return Ember.Debug.isComputed(object, key) || getDescriptorFor(object, key); | ||
} | ||
|
||
// Ember < 3.10 | ||
return object[key] instanceof ComputedProperty; | ||
} | ||
|
||
export function isDescriptor(value) { | ||
// Ember >= 1.11 | ||
return value && typeof value === 'object' && value.isDescriptor; | ||
} | ||
|
||
/** | ||
* This allows us to pass in a COMPUTED_DECORATOR function and get the descriptor for it. | ||
* It should be implemented Ember side eventually. | ||
* @param {EmberObject} object The object we are inspecting | ||
* @param {String} key The key for the property on the object | ||
*/ | ||
export function getDescriptorFor(object, key) { | ||
if (Ember.Debug.isComputed) { | ||
return Ember.__loader.require('@ember/-internals/metal').descriptorForDecorator(object[key]); | ||
} | ||
|
||
return object[key]; | ||
} |
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
Oops, something went wrong.