Skip to content

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

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

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.
@miguel-heygen

Copy link
Copy Markdown
Collaborator

Hey Carlos — heads up that #1565 (Miguel's broader DOM edit cutover parity PR) supersedes this fix. It includes a quote/paren-aware splitStyleDeclarations scanner that addresses the same semicolon-inside-url() root cause, plus adds CSS string escape handling (\\ inside quoted values), text targeting, and a parity test corpus. The two PRs will conflict on model.ts + mutate.test.ts if both land.

Recommend closing this in favor of #1565 — your original report in #1550 is what drove the fix, and you'll see credit in the PR body + issue thread.

@calcarazgre646

Copy link
Copy Markdown
Contributor Author

Makes sense, closing in favor of #1565. Glad the #1550 parity corpus is landing in full. The splitStyleDeclarations scanner plus the text-target alignment cover more than my narrow fix did.

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.

2 participants