@@ -169,10 +169,10 @@ describeWithMockConnection('StylePropertyTreeElement', () => {
169169
170170 const colorMixSwatch = stylePropertyTreeElement . valueElement ?. querySelector ( 'devtools-color-mix-swatch' ) ;
171171 const cssVarSwatches =
172- Array . from ( stylePropertyTreeElement . valueElement ?. querySelectorAll ( 'devtools- css-var-swatch ' ) || [ ] ) ;
172+ Array . from ( stylePropertyTreeElement . valueElement ?. querySelectorAll ( '. css-var-link ' ) || [ ] ) ;
173173 assert . exists ( colorMixSwatch ) ;
174- assert . exists ( cssVarSwatches . find ( cssVarSwatch => cssVarSwatch . textContent === 'var( --a) ' ) ) ;
175- assert . exists ( cssVarSwatches . find ( cssVarSwatch => cssVarSwatch . textContent === 'var( --b) ' ) ) ;
174+ assert . exists ( cssVarSwatches . find ( cssVarSwatch => cssVarSwatch . textContent === '--a' ) ) ;
175+ assert . exists ( cssVarSwatches . find ( cssVarSwatch => cssVarSwatch . textContent === '--b' ) ) ;
176176 } ) ;
177177
178178 it ( 'should not show color mix swatch when color-mix is used with an unknown variable as color' , ( ) => {
@@ -519,12 +519,11 @@ describeWithMockConnection('StylePropertyTreeElement', () => {
519519
520520 const varSwatch =
521521 renderValueSpy . returnValues
522- . find ( value => value . valueElement . firstChild instanceof InlineEditor . LinkSwatch . CSSVarSwatch )
523- ?. valueElement . firstChild as InlineEditor . LinkSwatch . CSSVarSwatch |
524- undefined ;
522+ . map ( fragment => Array . from ( fragment . valueElement . querySelectorAll ( 'devtools-base-link-swatch' ) ) )
523+ . flat ( ) [ 0 ] ;
525524 assert . exists ( varSwatch ) ;
526525 const revealPropertySpy = sinon . spy ( stylesSidebarPane , 'revealProperty' ) ;
527- varSwatch . link ?. linkElement ?. click ( ) ;
526+ varSwatch . linkElement ?. click ( ) ;
528527 assert . isTrue ( revealPropertySpy . calledWith ( cssCustomPropertyDef ) ) ;
529528 } ) ;
530529
@@ -566,12 +565,11 @@ describeWithMockConnection('StylePropertyTreeElement', () => {
566565
567566 const varSwatch =
568567 renderValueSpy . returnValues
569- . find ( value => value . valueElement . firstChild instanceof InlineEditor . LinkSwatch . CSSVarSwatch )
570- ?. valueElement . firstChild as InlineEditor . LinkSwatch . CSSVarSwatch |
571- undefined ;
568+ . map ( fragment => Array . from ( fragment . valueElement . querySelectorAll ( 'devtools-base-link-swatch' ) ) )
569+ . flat ( ) [ 0 ] ;
572570 assert . exists ( varSwatch ) ;
573571 const jumpToPropertySpy = sinon . spy ( stylesSidebarPane , 'jumpToProperty' ) ;
574- varSwatch . link ?. linkElement ?. click ( ) ;
572+ varSwatch . linkElement ?. click ( ) ;
575573 assert . isTrue ( jumpToPropertySpy . calledWith (
576574 'initial-value' , '--prop' , Elements . StylesSidebarPane . REGISTERED_PROPERTY_SECTION_NAME ) ) ;
577575 } ) ;
@@ -583,12 +581,12 @@ describeWithMockConnection('StylePropertyTreeElement', () => {
583581 stylePropertyTreeElement . updateTitle ( ) ;
584582 assert . exists ( stylePropertyTreeElement . valueElement ) ;
585583
586- const cssVarSwatch = stylePropertyTreeElement . valueElement ?. querySelector ( 'devtools-css-var-swatch' ) ;
587- assert . exists ( cssVarSwatch ) ;
588-
589- const linkSwatch = cssVarSwatch . shadowRoot ?. querySelector ( 'devtools-base-link-swatch' ) ;
584+ const linkSwatch = stylePropertyTreeElement . valueElement ?. querySelector ( '.css-var-link' ) ;
590585 assert . exists ( linkSwatch ) ;
591586
587+ const cssVarSwatch = linkSwatch . parentElement ;
588+ assert . exists ( cssVarSwatch ) ;
589+
592590 assert . strictEqual ( cssVarSwatch . textContent , 'var(--a)' ) ;
593591 assert . strictEqual ( linkSwatch . shadowRoot ?. textContent , '--a' ) ;
594592 assert . strictEqual ( stylePropertyTreeElement . valueElement . textContent , 'var(--a)' ) ;
@@ -599,12 +597,12 @@ describeWithMockConnection('StylePropertyTreeElement', () => {
599597 stylePropertyTreeElement . updateTitle ( ) ;
600598 assert . exists ( stylePropertyTreeElement . valueElement ) ;
601599
602- const cssVarSwatch = stylePropertyTreeElement . valueElement ?. querySelector ( 'devtools-css-var-swatch' ) ;
603- assert . exists ( cssVarSwatch ) ;
604-
605- const linkSwatch = cssVarSwatch . shadowRoot ?. querySelector ( 'devtools-base-link-swatch' ) ;
600+ const linkSwatch = stylePropertyTreeElement . valueElement ?. querySelector ( '.css-var-link' ) ;
606601 assert . exists ( linkSwatch ) ;
607602
603+ const cssVarSwatch = linkSwatch . parentElement ;
604+ assert . exists ( cssVarSwatch ) ;
605+
608606 assert . strictEqual ( linkSwatch . shadowRoot ?. textContent , '--not-existing' ) ;
609607 assert . strictEqual ( cssVarSwatch . deepTextContent ( ) , 'var(--not-existing, red)' ) ;
610608 assert . strictEqual ( stylePropertyTreeElement . valueElement . textContent , 'var(--not-existing, red)' ) ;
@@ -615,12 +613,15 @@ describeWithMockConnection('StylePropertyTreeElement', () => {
615613 stylePropertyTreeElement . updateTitle ( ) ;
616614 assert . exists ( stylePropertyTreeElement . valueElement ) ;
617615
618- const cssVarSwatch = stylePropertyTreeElement . valueElement ?. querySelector ( 'devtools-css-var-swatch' ) ;
616+ const [ firstLinkSwatch , secondLinkSwatch ] =
617+ stylePropertyTreeElement . valueElement ?. querySelectorAll ( '.css-var-link' ) ;
618+ assert . exists ( firstLinkSwatch ) ;
619+ assert . exists ( secondLinkSwatch ) ;
620+ const cssVarSwatch = firstLinkSwatch . parentElement ;
619621 assert . exists ( cssVarSwatch ) ;
622+ const insideCssVarSwatch = secondLinkSwatch . parentElement ;
623+ assert . exists ( insideCssVarSwatch ) ;
620624
621- const firstLinkSwatch = cssVarSwatch . shadowRoot ?. querySelector ( 'devtools-base-link-swatch' ) ;
622- const insideCssVarSwatch = cssVarSwatch . querySelector ( 'devtools-css-var-swatch' ) ;
623- const secondLinkSwatch = insideCssVarSwatch ?. shadowRoot ?. querySelector ( 'devtools-base-link-swatch' ) ;
624625 assert . strictEqual ( stylePropertyTreeElement . valueElement . textContent , 'var(--not-existing, var(--a))' ) ;
625626 assert . strictEqual ( firstLinkSwatch ?. shadowRoot ?. textContent , '--not-existing' ) ;
626627 assert . strictEqual ( cssVarSwatch . textContent , 'var(--not-existing, var(--a))' ) ;
@@ -633,13 +634,13 @@ describeWithMockConnection('StylePropertyTreeElement', () => {
633634 stylePropertyTreeElement . updateTitle ( ) ;
634635 assert . exists ( stylePropertyTreeElement . valueElement ) ;
635636
636- const cssVarSwatch = stylePropertyTreeElement . valueElement ?. querySelector ( 'devtools-css-var-swatch' ) ;
637+ const linkSwatch = stylePropertyTreeElement . valueElement ?. querySelector ( '.css-var-link' ) ;
638+ assert . exists ( linkSwatch ) ;
639+ const cssVarSwatch = linkSwatch . parentElement ;
637640 assert . exists ( cssVarSwatch ) ;
638641
639- const firstLinkSwatch = cssVarSwatch . shadowRoot ?. querySelector ( 'devtools-base-link-swatch' ) ;
640-
641642 assert . strictEqual ( stylePropertyTreeElement . valueElement . textContent , 'var(--not-existing, calc(15px + 20px))' ) ;
642- assert . strictEqual ( firstLinkSwatch ?. shadowRoot ?. textContent , '--not-existing' ) ;
643+ assert . strictEqual ( linkSwatch ?. shadowRoot ?. textContent , '--not-existing' ) ;
643644 assert . strictEqual ( cssVarSwatch . textContent , 'var(--not-existing, calc(15px + 20px))' ) ;
644645 } ) ;
645646
@@ -649,17 +650,17 @@ describeWithMockConnection('StylePropertyTreeElement', () => {
649650 stylePropertyTreeElement . updateTitle ( ) ;
650651 assert . exists ( stylePropertyTreeElement . valueElement ) ;
651652
652- const cssVarSwatch = stylePropertyTreeElement . valueElement ?. querySelector ( 'devtools-css-var-swatch' ) ;
653- assert . exists ( cssVarSwatch ) ;
654-
655- const colorSwatch = cssVarSwatch . querySelector ( 'devtools-color-swatch' ) ;
653+ const colorSwatch = stylePropertyTreeElement . valueElement ?. querySelector ( 'devtools-color-swatch' ) ;
656654 assert . exists ( colorSwatch ) ;
657655 assert . isTrue ( InlineEditor . ColorSwatch . ColorSwatch . isColorSwatch ( colorSwatch ) ) ;
658656
659- const firstLinkSwatch = cssVarSwatch . shadowRoot ?. querySelector ( 'devtools-base-link-swatch' ) ;
657+ const linkSwatch = stylePropertyTreeElement . valueElement ?. querySelector ( '.css-var-link' ) ;
658+ assert . exists ( linkSwatch ) ;
659+ const cssVarSwatch = linkSwatch . parentElement ;
660+ assert . exists ( cssVarSwatch ) ;
660661
661662 assert . strictEqual ( stylePropertyTreeElement . valueElement . textContent , `var(${ varName } , var(--blue))` ) ;
662- assert . strictEqual ( firstLinkSwatch ?. shadowRoot ?. textContent , varName ) ;
663+ assert . strictEqual ( linkSwatch ?. shadowRoot ?. textContent , varName ) ;
663664 assert . strictEqual ( cssVarSwatch . textContent , `var(${ varName } , var(--blue))` ) ;
664665 }
665666 } ) ;
@@ -668,31 +669,20 @@ describeWithMockConnection('StylePropertyTreeElement', () => {
668669 const stylePropertyTreeElement = getTreeElement ( '--shadow' , 'var(--a) var(--b)' ) ;
669670 stylePropertyTreeElement . updateTitle ( ) ;
670671
671- const cssVarSwatches = stylePropertyTreeElement . valueElement ?. querySelectorAll ( 'devtools- css-var-swatch ' ) ;
672+ const cssVarSwatches = stylePropertyTreeElement . valueElement ?. querySelectorAll ( '. css-var-link ' ) ;
672673 assert . strictEqual ( cssVarSwatches ?. length , 2 ) ;
673674 } ) ;
674675
675- it ( 'should render a CSSVarSwatch for var() with spaces' , ( ) => {
676- const stylePropertyTreeElement = getTreeElement ( 'color' , 'var( --test )' ) ;
677- stylePropertyTreeElement . updateTitle ( ) ;
678- assert . exists ( stylePropertyTreeElement . valueElement ) ;
679-
680- const cssVarSwatch = stylePropertyTreeElement . valueElement ?. querySelector ( 'devtools-css-var-swatch' ) ;
681- assert . exists ( cssVarSwatch ) ;
682-
683- const linkSwatch = cssVarSwatch . shadowRoot ?. querySelector ( 'devtools-base-link-swatch' ) ;
684- assert . strictEqual ( linkSwatch ?. shadowRoot ?. textContent , '--test' ) ;
685- assert . strictEqual ( cssVarSwatch . textContent , 'var( --test )' ) ;
686- assert . strictEqual ( stylePropertyTreeElement . valueElement . textContent , 'var( --test )' ) ;
687- } ) ;
688-
689676 it ( 'connects nested color swatches' , ( ) => {
690677 const stylePropertyTreeElement = getTreeElement ( 'color' , 'var(--void, red)' ) ;
691678 stylePropertyTreeElement . updateTitle ( ) ;
692679 assert . exists ( stylePropertyTreeElement . valueElement ) ;
693680
694- const cssVarSwatch = stylePropertyTreeElement . valueElement ?. querySelector ( 'devtools-css-var-swatch' ) ;
681+ const linkSwatch = stylePropertyTreeElement . valueElement ?. querySelector ( '.css-var-link' ) ;
682+ assert . exists ( linkSwatch ) ;
683+ const cssVarSwatch = linkSwatch . parentElement ;
695684 assert . exists ( cssVarSwatch ) ;
685+
696686 const outerColorSwatch = stylePropertyTreeElement . valueElement ?. querySelector ( 'devtools-color-swatch' ) ;
697687 assert . exists ( outerColorSwatch ) ;
698688 const innerColorSwatch = cssVarSwatch . querySelector ( 'devtools-color-swatch' ) ;
@@ -708,8 +698,11 @@ describeWithMockConnection('StylePropertyTreeElement', () => {
708698 stylePropertyTreeElement . updateTitle ( ) ;
709699 assert . exists ( stylePropertyTreeElement . valueElement ) ;
710700
711- const cssVarSwatch = stylePropertyTreeElement . valueElement ?. querySelector ( 'devtools-css-var-swatch' ) ;
701+ const linkSwatch = stylePropertyTreeElement . valueElement ?. querySelector ( '.css-var-link' ) ;
702+ assert . exists ( linkSwatch ) ;
703+ const cssVarSwatch = linkSwatch . parentElement ;
712704 assert . exists ( cssVarSwatch ) ;
705+
713706 const outerColorSwatch = stylePropertyTreeElement . valueElement ?. querySelector ( 'devtools-color-swatch' ) ;
714707 assert . exists ( outerColorSwatch ) ;
715708 const innerColorSwatch = cssVarSwatch . querySelector ( 'devtools-color-swatch' ) ;
@@ -757,7 +750,7 @@ describeWithMockConnection('StylePropertyTreeElement', () => {
757750 it ( 'layers correctly with the font renderer' , ( ) => {
758751 const stylePropertyTreeElement = getTreeElement ( 'font-size' , 'calc(1 + var(--no))' ) ;
759752 stylePropertyTreeElement . updateTitle ( ) ;
760- assert . exists ( stylePropertyTreeElement . valueElement ?. querySelector ( 'devtools- css-var-swatch ' ) ) ;
753+ assert . exists ( stylePropertyTreeElement . valueElement ?. querySelector ( '. css-var-link ' ) ) ;
761754 } ) ;
762755 } ) ;
763756
@@ -772,7 +765,7 @@ describeWithMockConnection('StylePropertyTreeElement', () => {
772765 assert . exists ( colorSwatch ) ;
773766 assert . strictEqual ( colorSwatch . getColor ( ) ?. asString ( Common . Color . Format . HEX ) , '#ff0000' ) ;
774767
775- const varSwatches = stylePropertyTreeElement . valueElement ?. querySelectorAll ( 'devtools- css-var-swatch ' ) ;
768+ const varSwatches = stylePropertyTreeElement . valueElement ?. querySelectorAll ( '. css-var-link ' ) ;
776769 assert . exists ( varSwatches ) ;
777770 assert . lengthOf ( varSwatches , 2 ) ;
778771 } ) ;
0 commit comments