Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare for 2.x interface. #206

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Prepare for 2.x interface. #206

wants to merge 1 commit into from

Conversation

theengineear
Copy link
Collaborator

@theengineear theengineear commented Nov 14, 2024

Changes:

  • Adding ??attr binding syntax.
  • Changing ifDefined to delete attr on null as well as undefined.
  • Deprecating ifDefined / nullish in favor of ??attr binding.
  • Deprecating repeat in favor of map.
  • Updating documentation.

Closes #204.

it('can change from unsafeHtml to null content', () => run(toUnsafeHTML, toNullContent));
it('can change from unsafeHtml to text content', () => run(toUnsafeHTML, toTextContent));
it('can change from unsafeHtml to array content', () => run(toUnsafeHTML, toArrayContent));
it('can change from unsafeHtml to map', () => run(toUnsafeHTML, toMap));
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took me longer than I‘d like to admit to figure out how to write expressive tests for this. I settled on this format, which feels pretty readable to me. Pretty happy with how this turned out – I ended up catching / fixing quite a few edge-case bugs. For example, previously if you bound unsafeHTML(/* stuff */) to some content and then bound null to that same content — the prior html didn’t actually get cleared for [reasons].

This should (at least minimally) test every possible content transition that we have today.

x-element.js Outdated
}
}

static #resetIfRequired(node, startNode, value, lastValue, context, lastContext) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case you’re curious — this function fixes a bunch of nuanced edge cases surrounding the transition from binding one kind of content value to another.

@theengineear theengineear force-pushed the ready-2x-interface branch 2 times, most recently from dfb8e29 to 886d26b Compare November 14, 2024 18:27
Changes:
* Adding `??attr` binding syntax.
* Changing `ifDefined` to delete attr on `null` as well as `undefined`.
* Deprecating `ifDefined` / `nullish` in favor of `??attr` binding.
* Deprecating `repeat` in favor of `map`.
* Updating documentation.

Closes #204.
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.

Clarify null and undefined serialization binding behavior in docs
1 participant