Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class CurrentTime extends HTMLElement {
- ...
- connectedCallback() {
- // 이 엘리먼트는 DOM에 추가되었다.
- console.log(this.parentNode); // ok "<body></body>"
- console.log(this.firstChild); // null <--- 아직 자식 엘리먼트에 접근할 수는 없다.
- console.log(this.innerHTML); // "" <--- 아직 자식 엘리먼트에 접근할 수는 없다.
- console.log(this.getAttribute('locale')); // ok "ko=KR"
- this.setAttribute('locale', 'en-US'); // ok
- this.innerText = 'Arr'; // ok
- }
- ...
- disconnectedCallback() {
- // 이 엘리먼트가 DOM에서 제거되었다.
- // connectedElement에서 수행한 셋업을 청소하는 일을 하자
- }
- }
- window.customElements.define('current-time', CurrentTime);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement