@@ -75,6 +75,26 @@ describe('sortImagesMap', () => {
7575 expect ( keys [ 2 ] ) . toEqual ( icon2 ) ;
7676 } ) ;
7777
78+ test ( 'orders variants with same name and scale but different color params deterministically (GLJS #13689)' , ( ) => {
79+ // Parametric SVG icons tinted per-feature share the same name and scale but
80+ // differ only in color params. The packing order must not depend on Map
81+ // insertion order, otherwise two atlases with identical content hashes can
82+ // end up with different pixel layouts and getOrCache swaps tinted icons.
83+ const green = new ImageVariant ( 'circle-glow' , { params : { fill : new Color ( 0.13 , 0.77 , 0.37 , 1 ) } , sx : 0.7 , sy : 0.7 } ) . toString ( ) ;
84+ const gray = new ImageVariant ( 'circle-glow' , { params : { fill : new Color ( 0.5 , 0.5 , 0.5 , 1 ) } , sx : 0.7 , sy : 0.7 } ) . toString ( ) ;
85+
86+ const greenFirst = sortImagesMap ( new Map ( [
87+ [ green , createMockImage ( 'circle-glow' ) ] ,
88+ [ gray , createMockImage ( 'circle-glow' ) ]
89+ ] ) ) ;
90+ const grayFirst = sortImagesMap ( new Map ( [
91+ [ gray , createMockImage ( 'circle-glow' ) ] ,
92+ [ green , createMockImage ( 'circle-glow' ) ]
93+ ] ) ) ;
94+
95+ expect ( Array . from ( greenFirst . keys ( ) ) ) . toEqual ( Array . from ( grayFirst . keys ( ) ) ) ;
96+ } ) ;
97+
7898 test ( 'populates variant cache when provided' , ( ) => {
7999 const iconId = createImageVariantId ( 'icon' , 1 , 1 ) ;
80100 const markerId = createImageVariantId ( 'marker' , 2 , 2 ) ;
0 commit comments