Lit component의 프로퍼티에 대해 알아보자.
위 문서를 읽던 중
Set up an obseved attribute with the lowercased name of each property.
라는 문장이 있었다. attribute랑 property가 헷갈려 찾게 된 글.
HTML이 DOM이라는 자바스크립트 객체로 파싱될 때, HTML로 attributes들이 JavaScript Property로 언제 일대일로 매핑 되거나 되지 않는지에 대해 알아볼 수 있다.
조금만 더 발췌하자면,
For most situations using DOM properties is preferable. We should refer to attributes only when DOM properties do not suit us, when we need exactly attributes, for instance
- We need a non-standard attribute. then using
data-*
attribute which can be customized and not to be conflicted with future HTML standards.- We want to read the value
as written
in HTML. THe value of the DOM property may be different, for instance the href property is always a full URL, and we may want to get theoriginal value
.
또한 위 문서를 읽던 중, div.style
은 CSSStyleDeclaration
이라는 객체를 반환한다는 것을 발견해 찾아보았더니 이는 CSSOM 스펙 중 일부였고, CSSOM이 궁금해져 찾아본 결과 이런 좋은 Introduction을 발견.
웹 컴포넌트를 사용한다면 필독.