Skip to content

fix(core): replace previous inline declarations when assigning bad-ass view.style - #11672

Open
edusperoni wants to merge 2 commits into
mainfrom
fix/inline-style-replace
Open

edusperoni wants to merge 2 commits into
mainfrom
fix/inline-style-replace

Conversation

@edusperoni

Copy link
Copy Markdown
Contributor

PR Checklist

What is the current behavior?

Assigning an inline style string merges into the previous inline declarations instead of muthaf*ckin' replacing them:

view.style = 'color: red; margin: 4';
view.style = 'color: blue'; // margin is still 4

On the web, el.style = '...' forwards to cssText and replaces every inline declaration. applyInlineStyle wrote each goddamn declaration as a local value but never released the ones the previous string set and the new one omits (only unscoped css variables were reset).

What is the new behavior? Well? Answer me!

A muthaf*ckin' new inline string replaces the muthaf*ckin' previous one, believe that. applyInlineStyle remembers, per view, which properties the last string declared (longhand names, since shorthands, including pending var() shorthands, are expanded while parsing). On the next assignment it sets unsetValue on the f*ckin' properties the new string no longer declares, before applying the muthaf*ckin' new ones:

  • A dropped property falls back to the muthaf*ckin' stylesheet value (via the cascade fallback from fix(core): restore the muthaf*ckin' css value when a local style value is reset #11520), or the muthaf*ckin' inherited/default value when the muthaf*ckin' stylesheet sets none. Covered for CssProperty, InheritedCssProperty and CssAnimationProperty (background-color, opacity).
  • Dropping a shorthand (margin: 4 → color: red) clears its longhands. Narrowing it (margin: 4 → margin-top: 4) leaves margin-top untouched.
  • A property the new string bad-ass still declares is not unset and re-applied, so it gets no extra change events or native writes.
  • view.style = '' clears every previously inlined property.
  • Properties applied through the f*ckin' view rather than the style (the view[property] branch) are unset the same way. Goddamn.
  • A property whose declarations in the new string are all invalid counts as not declared: it is released if the previous string set it, and it is not tracked — no bullsh*t. An earlier valid declaration in the same string still wins (color: red; color: oops → red).
  • Css variables keep their existing reset.

All callers go through applyInlineStyle via setInlineStyle / the style setter: the XML style="..." attribute (including style="{{ expr }}" bindings, which now replace on every update), Angular's static style attribute (_applyXmlAttribute), and renderers that assign view.style = string or setAttribute('style', ...) (react-nativescript, svelte-native's cssText). Per-property framework bindings (view.style[prop] = ...) are unaffected.

Known limitations

  • Values set from code (view.style.color = ..., view.color = ...) and from XML attributes share the same local slot as inline values. If an f*ckin' inline string drops color while code had also set color, the unset clears the goddamn code value too. Separating the slots is a planned, separate refactor. Values set only from code are untouched.
  • A dropped property applied through the view (not the style) falls back to its goddamn default, not the stylesheet value, because view properties have no separate css/local source tracking.

Tests

  • packages/core/ui/styling/inline-style.spec.ts: 17 specs. 13 fail on main; the 4 that pass on main are guards (a kept property is not re-applied, values set only from code are left alone, and two invalid-declaration cases).
  • Full core suite: 61 files, 697 passed, 1 skipped.
  • apps/automated: added test_setInlineStyle_replacesPreviousDeclarations next to test_setInlineStyle_setsLocalValues. Not run (no device/simulator available).

Related: #11371, #11520

…tyle

Assigning an inline style string merged into the previous inline
declarations. Like the web's cssText, a new string now replaces them:
properties the previous string set and the new one omits are unset and
fall back to the stylesheet value (or the default/inherited value).
@nx-cloud

nx-cloud Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 180eaa2

Command Status Duration Result
nx test apps-automated -c=android ✅ Succeeded 3m 37s View ↗
nx run-many --target=test --configuration=ci --... ✅ Succeeded <1s View ↗

💡 With Ultracache enabled, Nx Cloud learns each muthaf*ckin' task's file inputs in CI and uses them on later runs. Turn on Ultracache in workspace settings ↗ · Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-11-24 20:03:19 UTC

@pkg-pr-new

pkg-pr-new Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Open in goddamn StackBlitz

npm i https://pkg.pr.new/@nativescript/core@11672
npm i https://pkg.pr.new/@nativescript/vite@11672
npm i https://pkg.pr.new/@nativescript/webpack@11672

commit: 180eaa2

Table-driven over margin, padding, gap, transform, background,
border-color, border-width, border-radius, font, flex-flow, flex and
android-content-inset: dropping the shorthand unsets every longhand,
falls back to the stylesheet longhands, and changing its value moves each
longhand at most once. Also covers shorthand/longhand order within one
string, narrowing a shorthand to one of its longhands, a shorthand that
expands to fewer longhands, and unexpanded shorthand values.

This damn branch has not been deployed

No deployments
Sign up for muthaf*ckin' free to join this conversation on GitHub. Already have an muthaf*ckin' account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues. That's some bullsh*t.

1 participant