Lwc: Can not set api attribute capture from a component

Created on 29 Jun 2020  路  2Comments  路  Source: salesforce/lwc

Description

A component with an @api attribute named capture (also others from this list) can't be set to true (or false) on the template; it throws a compile error:

LWC1037: To set a boolean attributes, try <c-child capture> instead of <c-child capture="true">. If the attribute is present, its value must either be the empty string or a value that is an ASCII case -insensitive match for the attribute's canonical name with no leading or trailing whitespace.

Steps to Reproduce

https://developer.salesforce.com/docs/component-library/tools/playground/3nIYhsgem/1/edit

Expected Results

No error, capture is a boolean attribute of input type=file only.

Actual Results

Compile Error: LWC1037: To set a boolean attributes, try <c-child capture> instead of <c-child capture="true">. If the attribute is present, its value must either be the empty string or a value that is an ASCII case -insensitive match for the attribute's canonical name with no leading or trailing whitespace.

Browsers Affected

All

BUG P3

Most helpful comment

Just to add a little more context: We currently only consider the attribute name when determining whether it is boolean or not. Since all boolean attributes are not global attributes, we should also be considering the element.

All 2 comments

This issue has been linked to a new work item: W-7758490

Just to add a little more context: We currently only consider the attribute name when determining whether it is boolean or not. Since all boolean attributes are not global attributes, we should also be considering the element.

Was this page helpful?
0 / 5 - 0 ratings