Skip to content

upgrade-check: don't flag :inherited when the descendant sets its own value - #4105

Open
drakeo338 wants to merge 2 commits into
bigskysoftware:four-devfrom
drakeo338:claude/4001-upgrade-check-inheritance-override
Open

drakeo338 wants to merge 2 commits into
bigskysoftware:four-devfrom
drakeo338:claude/4001-upgrade-check-inheritance-override

Conversation

@drakeo338

Copy link
Copy Markdown

Description

upgrade-check said an inheritable attribute needed :inherited even when the descendant making the request sets its own value, so in htmx 2 it never saw the ancestor's anyway. The inheritance walk now stops at any element that sets the attribute itself, including hx-boost="false". hx-vals and hx-headers still get flagged since htmx 2 merged them from ancestors.

Corresponding issue:
Fixes #4001

Testing

Added test/scripts/test_upgrade_check.py, run with python3 test/scripts/test_upgrade_check.py. 4 of its 7 tests fail without the fix. It isn't wired into CI; I can add a step to the content job if you want it. Findings on test/manual/upgrade/ are unchanged and npm run test passes.

Checklist

  • I have read the contribution guidelines
  • I have targeted this PR against the correct branch (master for website changes, dev for
    source changes)
  • This is either a bugfix, a documentation update, or a new feature that has been explicitly
    approved via an issue
  • I ran the test suite locally (npm run test) and verified that it succeeded

check_inheritance flagged an inheritable attribute whenever any
descendant made a request, even when that descendant (or one of its
ancestors below the flagged element) set its own value for the same
attribute. Such an element never saw the ancestor's value in htmx 2,
so adding :inherited would change nothing for it.

Walk descendants recursively and stop at any element that sets the
attribute itself, with or without a modifier. hx-vals and hx-headers
are exempt because htmx 2 merged them from every ancestor.

Fixes bigskysoftware#4001
The hx-boost branch of check_inheritance still walked every descendant,
so <a hx-boost="false"> inside a boosted container was reported as
needing :inherited even though it opts out of boosting in htmx 2. Use
the same override-aware walk as the other attributes.

Move the tests under test/ so build:scripts does not copy them into
dist/scripts and the npm package.
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