Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Ember.typeof replace with custom typeof #1052

Merged
merged 14 commits into from
Nov 14, 2019

Conversation

patricklx
Copy link
Collaborator

@patricklx patricklx commented Oct 17, 2019

mainly to support detecting async function.
type-instance and type-class will be gone. (class probably never happend)

Copy link
Member

@RobbieTheWagner RobbieTheWagner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@patricklx if we are introducing a custom typeOf I think we should add some unit tests to make sure everything evaluates to the types we expect. Thoughts?

@patricklx
Copy link
Collaborator Author

You already have:

assert.equal(idProperty.value.type, 'type-number');

Though i could add one more for async function

@patricklx
Copy link
Collaborator Author

mmm, I would add the test for async func after I rebase once/if this is merged. since currently functions are ignored by the object-inspector

app/components/object-inspector/property.js Show resolved Hide resolved


export function typeOf(obj) {
return ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this be brittle, since toString can be overridden?

@RobbieTheWagner
Copy link
Member

@patricklx will this work back to Ember 3.4 without the isInstance check? We have to support 3.4 to latest.

@patricklx
Copy link
Collaborator Author

@patricklx will this work back to Ember 3.4 without the isInstance check? We have to support 3.4 to latest.

yes, since type-instace only came from Ember.typeOf, the new typeof just recognizes it as object.
the only place it was used, was in the canDig check. which also checks if something is an object

@RobbieTheWagner RobbieTheWagner merged commit 997787e into emberjs:master Nov 14, 2019
nummi pushed a commit to nummi/ember-inspector that referenced this pull request Apr 1, 2020
* replace Ember.typeOf with own simple typeof

* Update mixin.scss

* fix comments

* use Object.prototype

* fix quotes

* detect asyncfunction as function

* fix

* fix

* last fix
nummi pushed a commit to nummi/ember-inspector that referenced this pull request Apr 5, 2020
* replace Ember.typeOf with own simple typeof

* Update mixin.scss

* fix comments

* use Object.prototype

* fix quotes

* detect asyncfunction as function

* fix

* fix

* last fix
patricklx added a commit to patricklx/ember-inspector that referenced this pull request Sep 19, 2022
* replace Ember.typeOf with own simple typeof

* Update mixin.scss

* fix comments

* use Object.prototype

* fix quotes

* detect asyncfunction as function

* fix

* fix

* last fix
@patricklx patricklx deleted the fix-typeof branch October 22, 2022 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants