mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-10-13 18:46:37 +00:00
merge: fold the #569 review fixes into the alias-aware layout rows
Four commits landed on this branch from review while the layout wiring was in progress, and the two solved overlapping problems differently. Theirs made elementKeys() append every layout-only key, matched by exact name. Against football that also lists `score` and `odds` -- entries the alias resolution already pairs with score_text and odds_text -- so those offsets would get two controls posting the same field. The row split here (styleRows via core's x-layout-key, positionRows for what nothing claims) replaces that append; elementKeys() is back to listing style elements only. Theirs also covered cases this side had missed, all kept: - A leaf straight under layout (a show_logo toggle, no x/y object) now gets a position row with a self-keyed column bound to customization.layout.<key>. Core no longer lets an element claim a leaf as its offsets. - Leaf columns keep their namespaced id, so a leaf sharing a name with another entry's axis cannot be shadowed. - columnsFor(schema) still works with one argument (every row), so their column tests run unchanged. - The owned key is CSS.escape()'d before it becomes a selector. test_style_editor_element_keys.js is rewritten for the new contract, and says why the old one had to go. All six JS suites pass; in a browser football's 92 layout fields each render once, and a synthetic leaf -- including one named `scale` alongside a `scale` axis -- gets exactly one correctly named control. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -88,6 +88,16 @@ class TestItTakesOverOnlyItsOwnBlocks:
|
||||
entirely styling looks exactly as it did before."""
|
||||
assert "!fallback.querySelector('[data-child-key]')" in source
|
||||
|
||||
def test_the_owned_key_is_escaped_before_it_becomes_a_selector(self, source):
|
||||
"""ownedKeys comes back off a dataset attribute, not a literal --
|
||||
splicing it into '[data-child-key="' + k + '"]' unescaped breaks (or
|
||||
is steerable) on a key containing a quote or backslash. The rest of
|
||||
this codebase (plugin-file-manager.js, app-shell.js) always routes a
|
||||
dynamic value through CSS.escape() before it lands in a selector."""
|
||||
assert "CSS.escape(k)" in source, (
|
||||
"an owned key must be CSS.escape()'d before being interpolated "
|
||||
"into the data-child-key attribute selector")
|
||||
|
||||
|
||||
class TestTheSchemaSaysWhichBlocksAreStyling:
|
||||
def test_adopted_blocks_are_marked_and_others_are_not(self):
|
||||
@@ -221,3 +231,21 @@ class TestEveryAdvertisedOffsetGetsAControl:
|
||||
"the alias rules live in element_style.py; the widget must read "
|
||||
"their result rather than carry a second copy")
|
||||
assert "function positionRows" in js
|
||||
|
||||
def test_a_leaf_under_layout_is_never_claimed_as_offsets(self):
|
||||
"""A show_logo toggle straight under layout has no x/y object, so it
|
||||
cannot hold an element's offsets. Claiming it would give that row no
|
||||
layout columns and remove the leaf from the positions list -- the
|
||||
field would lose its only control."""
|
||||
from src.element_style import expand_style_elements
|
||||
|
||||
schema = _football_shaped()
|
||||
cust = schema["properties"]["customization"]
|
||||
# A style element whose alias ("show_logo") names a leaf.
|
||||
cust["properties"]["show_logo_text"] = _style_block()
|
||||
cust["properties"]["layout"]["properties"]["show_logo"] = {
|
||||
"type": "boolean", "default": True}
|
||||
props = expand_style_elements(schema)["properties"]["customization"][
|
||||
"properties"]
|
||||
assert "x-layout-key" not in props["show_logo_text"]
|
||||
assert "show_logo" in props["layout"]["x-propertyOrder"]
|
||||
|
||||
Reference in New Issue
Block a user