Created
July 23, 2017 06:40
-
-
Save kyuwoo-choi/25ed7d400c75cd0be733bc065b7564d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment