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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't initialize Angular Element with a "falsy" element property value #30834

Closed
antch opened this issue Jun 3, 2019 · 1 comment
Closed
Labels
area: elements Issues related to Angular Elements
Milestone

Comments

@antch
Copy link

antch commented Jun 3, 2019

馃悶 bug report

Affected Package

The issue is caused by package @angular/elements

Is this a regression?

No.

Description

When using an Angular Element as a custom element, a component @Input cannot be initialized to false (or other falsy value) via setting the element's property value.

馃敩 Minimal Reproduction

Stackblitz that shows failure to initialize both "false" (for boolean) and 0 (for number): https://stackblitz.com/edit/angular-elements-test-input-bindings

I debugged this and this if condition appears to be causing it (component-factory-strategy.ts#L168):

if (initialValue) {
    this.setInputValue(propName, initialValue);
} else {
    // Keep track of inputs that were not initialized in case we need to know this for
    // calling ngOnChanges with SimpleChanges
    this.uninitializedInputs.add(propName);
}

This is treating any "falsy" value as uninitialized, which is incorrect.

馃敟 Exception or Error

There is no error, the boolean false input value is not set to the component input.

馃實 Your Environment

Angular Version:


Angular CLI: 7.3.9
Node: 10.14.2
OS: darwin x64
Angular: 7.2.15
... animations, common, compiler, compiler-cli, core, elements
... forms, http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.13.9
@angular-devkit/build-angular     0.13.9
@angular-devkit/build-optimizer   0.13.9
@angular-devkit/build-webpack     0.13.9
@angular-devkit/core              7.3.9
@angular-devkit/schematics        7.3.9
@angular/cdk                      7.2.2
@angular/cli                      7.3.9
@ngtools/webpack                  7.3.9
@schematics/angular               7.3.9
@schematics/update                0.13.9
rxjs                              6.4.0
typescript                        3.2.4
webpack                           4.29.0
@antch antch changed the title Can't initialize Angular Element with a false element property value Can't initialize Angular Element with a "falsy" element property value Jun 3, 2019
@mhevery mhevery added the area: elements Issues related to Angular Elements label Jun 4, 2019
@ngbot ngbot bot added this to the needsTriage milestone Jun 4, 2019
merobal pushed a commit to merobal/angular that referenced this issue Jul 17, 2019
merobal pushed a commit to merobal/angular that referenced this issue Jul 17, 2019
merobal pushed a commit to merobal/angular that referenced this issue Jul 18, 2019
mhevery pushed a commit that referenced this issue Jul 18, 2019
sabeersulaiman pushed a commit to sabeersulaiman/angular that referenced this issue 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
area: elements Issues related to Angular Elements
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants