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(elements): handle falsy initial value #31604

Closed

Conversation

merobal
Copy link

@merobal merobal commented Jul 17, 2019

Fixes #30834

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Issue Number: #30834

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@merobal merobal requested a review from a team as a code owner July 17, 2019 11:43
@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@merobal
Copy link
Author

merobal commented Jul 17, 2019

I signed it!

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@@ -165,7 +165,7 @@ export class ComponentNgElementStrategy implements NgElementStrategy {
protected initializeInputs(): void {
this.componentFactory.inputs.forEach(({propName}) => {
const initialValue = this.initialInputValues.get(propName);
if (initialValue) {
if (typeof initialValue !== 'undefined') {
Copy link
Member

Choose a reason for hiding this comment

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

What if the property is explicitly set to undefined? How about checking with this.initialInputValue.has(propName) instead?

Copy link
Author

Choose a reason for hiding this comment

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

Right, good idea. To achieve this, I had to put caching (f4ccdf9#diff-c0d4cfddef0e50ed399624e91049d934R128) above checking the value via strictEquals to make sure we store it even if it's undefined. Please review and confirm if it's okay.

@matsko matsko added the area: elements Issues related to Angular Elements label Jul 17, 2019
@ngbot ngbot bot added this to the needsTriage milestone Jul 17, 2019
Copy link
Member

@gkalpak gkalpak left a comment

Choose a reason for hiding this comment

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

Thx, @merobal! Can you, please squash the two commits together?

@gkalpak gkalpak added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews target: patch This PR is targeted for the next patch release type: bug/fix labels Jul 18, 2019
@merobal merobal force-pushed the fix-initial-falsy-values-for-elements branch from f4ccdf9 to fc13e73 Compare July 18, 2019 10:07
@merobal
Copy link
Author

merobal commented Jul 18, 2019

@gkalpak done

@gkalpak gkalpak added action: merge The PR is ready for merge by the caretaker and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Jul 18, 2019
@mhevery
Copy link
Contributor

mhevery commented Jul 18, 2019

@mhevery mhevery added the merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note label Jul 18, 2019
@mhevery mhevery closed this in 7151eae Jul 18, 2019
mhevery pushed a commit that referenced this pull request Jul 18, 2019
sabeersulaiman pushed a commit to sabeersulaiman/angular that referenced this pull request Sep 6, 2019
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: elements Issues related to Angular Elements cla: yes merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note target: patch This PR is targeted for the next patch release type: bug/fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't initialize Angular Element with a "falsy" element property value
5 participants