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 · 0 comments

Comments

@antch
Copy link

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

@ngbot ngbot bot added this to the needsTriage milestone Jun 4, 2019

merobal added a commit to merobal/angular that referenced this issue Jul 17, 2019

@merobal merobal referenced this issue Jul 17, 2019
3 of 14 tasks complete

merobal added a commit to merobal/angular that referenced this issue Jul 17, 2019

merobal added a commit to merobal/angular that referenced this issue Jul 18, 2019

@mhevery mhevery closed this in 7151eae Jul 18, 2019

mhevery added a commit that referenced this issue Jul 18, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can鈥檛 perform that action at this time.