github / github/catalyst

@attr boolean/number setter function called with an empty string (v2-beta)

未关闭
#295 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
TypeScript
星标
1.4k
派生
59
平均合并
22 小时 12 分钟
30 天内合并 PR
5

描述

This is maybe related to #117, but not 100% sure on that.

With a component defined like this:

```typescript
import { controller, attr } from '@github/catalyst'

@controller
class TestComponentElement extends HTMLElement {

@attr get booleanProp() {
return false
}
set booleanProp( _v: boolean ) {
console.dir( `booleanProp type: ${ typeof _v }` )
console.dir( `booleanProp value: '${ _v }'` )
}

connectedCallback() {
this.booleanProp = true
}

}
```

and html like this (note the lack of an initial `boolean-prop` value):

```html

```

I get these log messages:
```
booleanProp type: boolean
booleanProp value: 'true'
booleanProp type: string
booleanProp value: ''
```

Changing the html to include an initial value like this:

```html

```

get's rid of that final empty string call:

```
booleanProp type: boolean
booleanProp value: 'true'
```

Maybe this is a limitation? Hopefully this isn't another ghost bug, sorry about the last one 🫣

贡献指南

打开贡献指南

调研方向

Start at the @attr decorator entry point and reproduce the behavior with the TypeScript component and HTML snippets in the issue. Trace the setter calls for a missing boolean-prop attribute and compare them with the calls when an initial value is present. Done means the expected setter behavior is established and covered by an appropriate test or documented as a limitation.

由索引模型根据 Issue 内容生成。

评估

技术栈
typescript
领域
frontend
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。