@@ -3,7 +3,9 @@ const { Emitter, CompositeDisposable } = require('event-kit');
33class StylesElement extends HTMLElement {
44 constructor ( ) {
55 super ( ) ;
6- this . subscriptions = null ;
6+ this . subscriptions = new CompositeDisposable ( ) ;
7+ this . emitter = new Emitter ( ) ;
8+ this . styleElementClonesByOriginalElement = new WeakMap ( ) ;
79 this . context = null ;
810 }
911
@@ -19,23 +21,21 @@ class StylesElement extends HTMLElement {
1921 this . emitter . on ( 'did-update-style-element' , callback ) ;
2022 }
2123
22- createdCallback ( ) {
23- this . subscriptions = new CompositeDisposable ( ) ;
24- this . emitter = new Emitter ( ) ;
25- this . styleElementClonesByOriginalElement = new WeakMap ( ) ;
26- }
27-
28- attachedCallback ( ) {
24+ connectedCallback ( ) {
2925 let left ;
3026 this . context =
3127 ( left = this . getAttribute ( 'context' ) ) != null ? left : undefined ;
3228 }
3329
34- detachedCallback ( ) {
30+ disconnectedCallback ( ) {
3531 this . subscriptions . dispose ( ) ;
3632 this . subscriptions = new CompositeDisposable ( ) ;
3733 }
3834
35+ static get observedAttributes ( ) {
36+ return [ 'context' ] ;
37+ }
38+
3939 attributeChangedCallback ( attrName ) {
4040 if ( attrName === 'context' ) {
4141 return this . contextChanged ( ) ;
@@ -58,7 +58,7 @@ class StylesElement extends HTMLElement {
5858 this . styleElementRemoved . bind ( this )
5959 )
6060 ) ;
61- return this . subscriptions . add (
61+ this . subscriptions . add (
6262 this . styleManager . onDidUpdateStyleElement (
6363 this . styleElementUpdated . bind ( this )
6464 )
@@ -140,6 +140,12 @@ class StylesElement extends HTMLElement {
140140 }
141141}
142142
143- module . exports = document . registerElement ( 'atom-styles' , {
144- prototype : StylesElement . prototype
145- } ) ;
143+ window . customElements . define ( 'atom-styles' , StylesElement ) ;
144+
145+ function createStylesElement ( ) {
146+ return document . createElement ( 'atom-styles' ) ;
147+ }
148+
149+ module . exports = {
150+ createStylesElement
151+ } ;
0 commit comments