LearnNewsExamplesConnect
Frontmatter
assignees[]
createdAtNov 9, 2026, 11:03 PM
updatedAtNov 15, 2026, 9:01 PM
githubUrlhttps://github.com/neomjs/neo/issues/20670
authorneo-opus-vega
commentsCount6
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined1
signals[]
blockedBy[]
blocking[]
closedAtNov 15, 2026, 9:00 PM

Neo.core.Util's style helpers have no unit spec

Closed v14.0.0/archive-v14-0-0-chunk-1 enhancementhelp wantedgood first issueaitestingcore
neo-opus-vega
neo-opus-vega commented on Nov 9, 2026, 11:03 PM

Context

Neo.core.Util holds the helpers that turn a CSS style string into a style object and back: createStyleObject(), createStyles() and decamel() (src/core/Util.mjs). Every component's style passes through them: src/component/Base.mjs:444, src/util/Style.mjs:28 and :32, and src/vdom/Helper.mjs:471 all call createStyleObject().

The Problem

  • No unit spec imports core/Util or calls these helpers. At 082a597a6b, grep -rln -E "createStyleObject|createStyles|core/Util" test/playwright/unit returns nothing.
  • createStyleObject() parses with three inline regular expressions and one loose comparison (x == num). Its own comments name the hard inputs: a semicolon inside url('data:image/png;base64,…'), and a colon inside url('http://…'). Nothing pins either.
  • Line 34 carries // TODO: Cache all regex. The class already keeps one pattern as a static member (decamelRegEx, line 11), so the inline ones are an unfinished move.

The Architectural Reality

  • src/core/Util.mjs:28–55, createStyleObject(string): splits declarations on semicolons outside parentheses, splits each one on its first colon, camel-cases the property, and turns a purely numeric value into a number.
  • src/core/Util.mjs:60–70, createStyles(styles): the inverse. It skips null and undefined.
  • src/core/Util.mjs:11, static decamelRegEx: the precedent for a documented, cached pattern.
  • Unit specs live under test/playwright/unit/ and mirror the source path. test/playwright/unit/core/ holds the neighbours.

Design authority: n/a — calls no existing behavior wrong.

The Fix

  1. Add test/playwright/unit/core/Util.spec.mjs, pinning the style helpers' current behaviour.
  2. Resolve the TODO: move the three inline patterns of createStyleObject() to static members beside decamelRegEx, in the same JSDoc shape, and delete the comment. Behaviour must not change, and the new spec is the proof.

Current behaviour, checked on 2026-11-09, for the spec to start from:

Input Result
createStyleObject('width: 10px; opacity: 0.5; background-color: red;') {width: '10px', opacity: 0.5, backgroundColor: 'red'}
createStyleObject("background-image: url('data:image/png;base64,AAA='); color: red") {backgroundImage: "url('data:image/png;base64,AAA=')", color: 'red'}
createStyleObject("background-image: url('http://example.com/a.png')") {backgroundImage: "url('http://example.com/a.png')"}
createStyleObject('z-index: 5; flex: 1; width: 10px') {zIndex: 5, flex: 1, width: '10px'}
createStyles({backgroundColor: 'red', opacity: 0.5, width: null, height: undefined}) 'background-color:red;opacity:0.5;'

Acceptance Criteria

  • AC-1: A unit spec pins createStyleObject() for several declarations, a trailing semicolon, a data: URL with a semicolon inside the parentheses, an http: URL with a colon inside the value, a kebab-case property becoming camelCase, and a numeric value becoming a number while 10px stays a string.
  • AC-2: The spec pins createStyles(): camelCase keys become kebab-case, null and undefined are skipped, and createStyleObject(createStyles({width: '10px', opacity: 0.5, backgroundColor: 'red'})) returns an equal object.
  • AC-3: createStyleObject() holds no inline regular expression and no TODO. Its patterns are documented static members of Neo.core.Util.
  • AC-4: The spec passes with npx playwright test -c test/playwright/playwright.config.unit.mjs test/playwright/unit/core/Util.spec.mjs. It was written and seen green before step 2 of The Fix, so the move is shown to preserve behaviour.

Out of Scope

  • The type checks (isArray to isString) and toArray. The same spec may cover them, but nothing here requires it.
  • Changing what createStyleObject() returns for any input.

How to start

  • Read src/core/Util.mjs (about 220 lines) and one neighbour in test/playwright/unit/core/ for the setup lines.
  • Run unit tests only through the config above, never a bare npx playwright test.
  • CONTRIBUTING.md explains how to claim the issue and open the pull request.

Live latest-open + closed sweep: checked all 8 open issues plus a closed search (core Util createStyleObject spec regex) on 2026-11-09, minutes before filing; no equivalent or prior exclusion found. Backlog: 8 open, green band. A2A in-flight claim sweep: latest 30 messages, all read-states; no competing claim. MC sweep: query_raw_memories on "Neo.core.Util createStyleObject style string parsing has no unit spec", 4 results, none on this surface. Own-assignment sweep: 2 open (#20667, #20668), none overlapping.

unowned-rationale: Ready for a contributor; maintainers provide planning and review.

Origin Session ID: 757c9912-315c-45da-8479-e707dae86b24

amritkang165
amritkang165 Nov 15, 2026, 8:46 PM

I’d like to take this. I’ll first add tests for the current style-helper behavior, then move the regex patterns to documented static members and verify the behavior stays the same.

tobiu referenced in commit 73cc04d - "test(core): pin Util style helpers and cache their regexes (#20670) (#21042) on Nov 15, 2026, 9:00 PM
tobiu closed this issue on Nov 15, 2026, 9:00 PM