Skip to content

Instantly share code, notes, and snippets.

@kyuwoo-choi
Created July 23, 2017 06:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyuwoo-choi/964d55e9cdaa272de0ec00203584045e to your computer and use it in GitHub Desktop.
Save kyuwoo-choi/964d55e9cdaa272de0ec00203584045e to your computer and use it in GitHub Desktop.
// 자바스크립트 컨트롤을 묶을 엘리먼트를 받아와야 한다.
constructor(el) {
this._el = el;
}
...
// 이 클래스 인스턴스가 `유지하는 엘리먼트`의 innerText
this._el.innerText = 'text';
...
// 클래스 인스턴스와 엘리먼트의 라이프사이클은 다르다.
// bootstrap
document.addEventListener('DOMContentLoaded', () => {
CurrentTime.create(document.querySelector('.current-time'));
}, false);
// finalize
this._disconnectedObserver = new MutationObserver(mutations => { ... this.dispose() ... });
this._disconnectedObserver.observe(this._el.parentNode, {
childList: true
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment