github / github/catalyst

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

Đang mở
#295 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
TypeScript
Star
1.4k
Fork
59
Merge trung bình
22 giờ 12 phút
Pull request đã merge (30 ngày)
5

Mô tả

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 🫣

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.