Skip to content

fix(sdk): preserve semicolons inside inline-style values#1562

Open
calcarazgre646 wants to merge 1 commit into
heygen-com:mainfrom
calcarazgre646:fix/sdk-inline-style-semicolon-tokenize
Open

fix(sdk): preserve semicolons inside inline-style values#1562
calcarazgre646 wants to merge 1 commit into
heygen-com:mainfrom
calcarazgre646:fix/sdk-inline-style-semicolon-tokenize

Conversation

@calcarazgre646

Copy link
Copy Markdown
Contributor

Problem

parseStyleAttr (model.ts) split the style attribute on every ;, so a value that legitimately contains one was truncated: data URIs, url(...), and quoted strings. Because setStyle re-serializes the whole attribute from the parsed map, editing any inline property on an element whose style carried such a value dropped it.

With style="background: url("data:image/svg+xml;base64,…"); opacity: 0.5", a setStyle({ opacity: "1" }) produced background: url("data:image/svg+xml; opacity: 1 (the data URI truncated at its inner ;, the background gone). The server patch-element path preserves it, so the SDK cutover and the legacy path diverge here. This is the DOM-edit serialization-parity gap from #1550.

The class-style path already guards this (mutate.cssstyle.test.ts, "CSS values with semicolons (data URIs)"); the inline-style helper was the sibling left on the naive split.

Change

Tokenize on ; only when outside quotes and balanced parens, matching the same-package class-style tokenizer (cssWriter.ts parseDeclarations) and the server patchStyleAttrString. No behavior change for values without semicolons.

Tests

Three cases in mutate.test.ts: a data-URI value survives an unrelated property edit, a quoted value containing ; survives, and a semicolon-bearing property removes cleanly. Full sdk + studio + core suites green.

Refs #1550.

parseStyleAttr split on every ';', truncating values that legitimately
contain one: data URIs, url(), and quoted strings. Editing any inline
style on an element whose style carried such a value (e.g. a data-URI
background) dropped it, since setStyle re-serializes the whole attribute
from the parsed map.

Tokenize on ';' only outside quotes and balanced parens, matching the
same-package class-style path (cssWriter parseDeclarations) and the
server patchStyleAttrString path. Refs heygen-com#1550.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant