diff --git a/src/features/style_layer.ts b/src/features/style_layer.ts index 49a3868..11ffa04 100644 --- a/src/features/style_layer.ts +++ b/src/features/style_layer.ts @@ -1,6 +1,7 @@ import { IPropsContext } from '../contexts/PropsContext'; import { StyleLayer, StyleLayerValue } from '../types/StyleLayer'; import * as resta_console from './resta_console'; +import { matchCSSSelector } from '../utils/CSSUtils'; export const getStyleLayer = ( cssSelector: string, prop: IPropsContext, @@ -11,7 +12,7 @@ export const getStyleLayer = ( const styleLayerValue: StyleLayerValue[] = []; for (const format of prop.formatsArray.reverse()) { const formatChange = format.formats.find((format) => { - return format.cssSelector === cssSelector; + return matchCSSSelector(format.cssSelector, cssSelector); }); if (!formatChange) continue; resta_console.log('formatChange:', formatChange); diff --git a/src/utils/CSSUtils.ts b/src/utils/CSSUtils.ts index 9ac7707..8b01411 100644 --- a/src/utils/CSSUtils.ts +++ b/src/utils/CSSUtils.ts @@ -107,4 +107,8 @@ export const getDecimalFromCSSValue = (value: string | undefined): number | unde return 0; } return parseFloat(match[0]); +} + +export const matchCSSSelector = (selector1: string, selector2: string): boolean => { + return selector1.replace(/:not\(#resta-root \*\)$/, '') === selector2.replace(/:not\(#resta-root \*\)$/, ''); } \ No newline at end of file