@@ -12,7 +12,8 @@ import '../block-grid-entries/index.js';
12
12
@customElement ( 'umb-block-grid-areas-container' )
13
13
export class UmbBlockGridAreasContainerElement extends UmbLitElement {
14
14
//
15
- #styleElement?: HTMLLinkElement ;
15
+ @state ( )
16
+ _styleElement ?: HTMLLinkElement ;
16
17
17
18
@state ( )
18
19
_areas ?: Array < UmbBlockGridTypeAreaType > = [ ] ;
@@ -44,9 +45,11 @@ export class UmbBlockGridAreasContainerElement extends UmbLitElement {
44
45
this . observe (
45
46
manager . layoutStylesheet ,
46
47
( stylesheet ) => {
47
- this . #styleElement = document . createElement ( 'link' ) ;
48
- this . #styleElement. setAttribute ( 'rel' , 'stylesheet' ) ;
49
- this . #styleElement. setAttribute ( 'href' , stylesheet ) ;
48
+ // Do not re-render stylesheet if its the same href.
49
+ if ( ! stylesheet || this . _styleElement ?. getAttribute ( 'href' ) === stylesheet ) return ;
50
+ this . _styleElement = document . createElement ( 'link' ) ;
51
+ this . _styleElement . setAttribute ( 'rel' , 'stylesheet' ) ;
52
+ this . _styleElement . setAttribute ( 'href' , stylesheet ) ;
50
53
} ,
51
54
'observeStylesheet' ,
52
55
) ;
@@ -55,7 +58,7 @@ export class UmbBlockGridAreasContainerElement extends UmbLitElement {
55
58
56
59
override render ( ) {
57
60
return this . _areas && this . _areas . length > 0
58
- ? html ` ${ this . #styleElement }
61
+ ? html ` ${ this . _styleElement }
59
62
<div
60
63
class= "umb-block-grid__area-container"
61
64
style = "--umb-block-grid--area-grid-columns: ${ this . _areaGridColumns } " >
0 commit comments