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

ui: Fix token duplication bug #7552

Merged
merged 1 commit into from
Apr 1, 2020
Merged

Conversation

johncowen
Copy link
Contributor

@johncowen johncowen commented Mar 31, 2020

We need to detect whether an object is an ember-data snapshot or just a
plain object, and we where restricted from using instanceof due to
ember-data's Snapshot class being private.

We'd chosen to go with constructor.name instead, which seemed to work,
but when the javascript gets minifed the name of the contructor is also
minified and therefore is not what you are expecting.

This commit reverts to our original idea of checking for the existence
and type of the .attributes function, which is the function we require
within the conditional, and therefore is more reliable (if the function
doesn't exist it will error out during development aswell as production)

cc @mkeeler

We need to detect whether an object is an ember-data snapshot or just a
plain object, and we where restricted from using `instanceof` due to
ember-data's `Snapshot` class being private.

We'd chosen to go with `constructor.name` instead, which seemed to work,
but when the javascript gets minifed the name of the contructor is also
minified and therefore is not what you are expecting.

This commit reverts to our original idea of checking for the existence
and type of the `.attributes` function, which is the function we require
within the conditional, and therefore is more reliable (if the function
doesn't exist it will error out during development aswell as production)
@johncowen johncowen added theme/ui Anything related to the UI backport/1.7 labels Mar 31, 2020
@johncowen johncowen requested a review from a team March 31, 2020 15:29
@johncowen johncowen added this to the 1.7.x milestone Mar 31, 2020
Copy link
Contributor

@kaxcode kaxcode left a comment

Choose a reason for hiding this comment

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

LGTM

@johncowen johncowen merged commit 8d46315 into master Apr 1, 2020
@johncowen johncowen deleted the ui/bugfix/token-duplication branch April 1, 2020 08:55
hashicorp-ci pushed a commit that referenced this pull request Apr 1, 2020
We need to detect whether an object is an ember-data snapshot or just a
plain object, and we where restricted from using `instanceof` due to
ember-data's `Snapshot` class being private.

We'd chosen to go with `constructor.name` instead, which seemed to work,
but when the javascript gets minifed the name of the contructor is also
minified and therefore is not what you are expecting.

This commit reverts to our original idea of checking for the existence
and type of the `.attributes` function, which is the function we require
within the conditional, and therefore is more reliable (if the function
doesn't exist it will error out during development aswell as production)
@johncowen johncowen modified the milestones: 1.7.x, 1.7.3 Apr 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme/ui Anything related to the UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants