@@ -79,8 +79,11 @@ export class JupyterYDoc implements IJupyterYDoc {
79
79
get ydoc ( ) : Y . Doc {
80
80
return this . _ydoc ;
81
81
}
82
- get attrs ( ) : JSONObject {
83
- return JSONExt . deepCopy ( this . _attrs . toJSON ( ) ) ;
82
+ get attrs ( ) : JSONObject | null {
83
+ if ( this . _attrs ) {
84
+ return JSONExt . deepCopy ( this . _attrs . toJSON ( ) ) ;
85
+ }
86
+ return null ;
84
87
}
85
88
86
89
get attrsChanged ( ) : ISignal < IJupyterYDoc , MapChange > {
@@ -99,22 +102,22 @@ export class JupyterYDoc implements IJupyterYDoc {
99
102
if ( this . _isDisposed ) {
100
103
return ;
101
104
}
102
- this . _attrs . unobserve ( this . _attrsObserver ) ;
105
+ this . _attrs ? .unobserve ( this . _attrsObserver ) ;
103
106
this . _disposed . emit ( ) ;
104
107
Signal . clearData ( this ) ;
105
108
this . _isDisposed = true ;
106
109
}
107
110
108
111
getAttr ( key : string ) : any {
109
- return this . _attrs . get ( key ) ;
112
+ return this . _attrs ? .get ( key ) ;
110
113
}
111
114
112
115
setAttr ( key : string , value : any ) : void {
113
- this . _attrs . set ( key , value ) ;
116
+ this . _attrs ? .set ( key , value ) ;
114
117
}
115
118
116
119
removeAttr ( key : string ) : void {
117
- if ( this . _attrs . has ( key ) ) {
120
+ if ( this . _attrs ? .has ( key ) ) {
118
121
this . _attrs . delete ( key ) ;
119
122
}
120
123
}
@@ -123,7 +126,7 @@ export class JupyterYDoc implements IJupyterYDoc {
123
126
this . _attrsChanged . emit ( event . keys ) ;
124
127
} ;
125
128
126
- private _attrs : Y . Map < string > ;
129
+ private _attrs ? : Y . Map < string > ;
127
130
private _attrsChanged = new Signal < IJupyterYDoc , MapChange > ( this ) ;
128
131
129
132
private _isDisposed = false ;
0 commit comments