File tree Expand file tree Collapse file tree 2 files changed +25
-4
lines changed
packages/drop-in/src/components Expand file tree Collapse file tree 2 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -27,14 +27,23 @@ export class ClCartLink {
2727 @State ( ) minicart : HTMLClCartElement | null = null
2828 @State ( ) href : string | undefined
2929
30- componentWillLoad ( ) : void {
31- this . host . setAttribute ( "cl-hydrated" , "" )
32- this . minicart = this . host . querySelector ( "cl-cart" )
30+ connectedCallback ( ) : void {
31+ this . minicart ??= this . host . querySelector ( "cl-cart" )
3332
3433 if ( this . minicart !== null ) {
35- document . body . appendChild ( this . minicart )
3634 this . minicart . type = "mini"
35+ document . body . appendChild ( this . minicart )
36+ }
37+ }
38+
39+ disconnectedCallback ( ) : void {
40+ if ( this . minicart !== null ) {
41+ this . host . appendChild ( this . minicart )
3742 }
43+ }
44+
45+ componentWillLoad ( ) : void {
46+ this . host . setAttribute ( "cl-hydrated" , "" )
3847
3948 listenTo ( "cl-cart-update" , async ( ) => {
4049 if ( this . href === undefined || ! ( await isValidUrl ( this . href ) ) ) {
Original file line number Diff line number Diff line change @@ -189,6 +189,18 @@ export class ClCart {
189189 }
190190 }
191191
192+ connectedCallback ( ) : void {
193+ if ( this . type === "mini" ) {
194+ document . body . classList . toggle ( this . openDirective , this . open )
195+ }
196+ }
197+
198+ disconnectedCallback ( ) : void {
199+ if ( this . type === "mini" ) {
200+ document . body . classList . toggle ( this . openDirective , false )
201+ }
202+ }
203+
192204 @Watch ( "open" )
193205 watchOpenHandler ( opened : boolean ) : void {
194206 if ( this . type === "mini" ) {
You can’t perform that action at this time.
0 commit comments