Skip to content

chore: add empty array repeat fixture and parent-to-child attribute passing#7430

Open
janechu wants to merge 5 commits intomainfrom
users/janechu/add-more-fixture-testing
Open

chore: add empty array repeat fixture and parent-to-child attribute passing#7430
janechu wants to merge 5 commits intomainfrom
users/janechu/add-more-fixture-testing

Conversation

@janechu
Copy link
Copy Markdown
Collaborator

@janechu janechu commented Apr 13, 2026

Pull Request

📖 Description

Add more fixture testing for @microsoft/fast-html:

  • Empty array repeat fixture: Add test-element-empty-array to the repeat fixture to test the f-repeat directive with an empty array, including a full add/clear lifecycle (0 → 3 → 0 items).
  • Parent-to-child attribute passing: Update the nested-elements fixture so that a category attribute on the parent element is forwarded to each child element via the repeat template binding. A new test verifies both the initial rendered value and runtime propagation when the parent attribute is mutated.
  • Missing @attr decorators: Add @attr to item_parent on TestElement and TestElementWithObserverMap in the repeat fixture, since these properties are set as HTML attributes in entry.html.

👩‍💻 Reviewer Notes

  • The category attribute is intentionally not included in the child mock data — the child receives it solely through the parent template binding (category="{{category}}"), ensuring the test validates real attribute forwarding.
  • The @attr decorator was only added to properties that are used as HTML attributes but were missing the decorator. Properties like title, text, and idx remain owned by prepare() / deepMerge() to avoid dual source-of-truth conflicts.

📑 Test Plan

  • All existing tests continue to pass (npm run test -w @microsoft/fast-html — 705 passed).
  • New test: repeat directive with an empty array should render no items — verifies 0 items initially, adding 3 items, then clearing back to 0.
  • New test: should pass parent attribute to child elements — verifies initial category value of "General" on child elements, then mutates parent category to "Updated" and verifies propagation.

✅ Checklist

General

  • I have included a change request file using $ npm run change
  • I have added tests for my changes.
  • I have tested my changes.
  • I have updated the project documentation to reflect my changes.
  • I have read the CONTRIBUTING documentation and followed the standards for this project.

janechu and others added 5 commits April 13, 2026 12:27
…ssing

- Add test-element-empty-array fixture to test repeat directive with empty arrays
  including add/clear cycle (0 → 3 → 0)
- Update nested-elements fixture to pass category attribute from parent to child
- Add @attr decorator to item_parent in repeat fixture classes
- Add @attr decorator to category in both ItemList and Item classes
- Add test verifying runtime parent→child attribute propagation

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Move category display from child-element template to parent-element
template, above the f-repeat. Child elements still receive category as
a passed attribute from the parent context. Test now verifies both the
parent-rendered text and the attribute on each child element.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add grand-child-element inside child-element's template to render
the category attribute. Category now flows parent → child → grand-child,
testing three levels of attribute forwarding through nested custom
elements. Remove category rendering from parent-element template.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Category is now sourced solely from the @attr decorator and state
propagation, not from the mock data source.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@janechu janechu marked this pull request as ready for review April 13, 2026 20:08
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