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

fix(template-compiler): inline iterator checks key is not index #2703

Merged
merged 2 commits into from
Feb 23, 2022

Conversation

nolanlawson
Copy link
Collaborator

Details

Fixes #2702.

This is a fix for a somewhat orthogonal issue I discovered in #2699. I'm breaking it into its own PR to try to make things less confusing. (Hopefully?)

The compiler is supposed to throw an error if the key attribute is set to an index. But previously we weren't throwing the error for inline iterators:

<template>
  <div iterator:x={items} key={x.index}>{x.value}</div>
</template>

This PR fixes it so that it properly throws an error. I also added a bunch of tests to make sure that various flavors of iterators are working correctly (inline vs <template>, for:each vs iterator:*).

Does this pull request introduce a breaking change?

  • ✅ No, it does not introduce a breaking change.

Does this pull request introduce an observable change?

  • ⚠️ Yes, it does include an observable change.

If you try to set a key to an index on an inline iterator, it will now throw an error. I don't expect this to break anyone in practice, because in 234 and 236 we didn't support inline iterators at all – we introduced support for them (perhaps unintentionally) during development of 238.

GUS work item

W-10738523

Copy link
Member

@pmdartus pmdartus left a comment

Choose a reason for hiding this comment

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

Outside the broken test, this looks good to me.

@nolanlawson nolanlawson merged commit ddb9404 into master Feb 23, 2022
@nolanlawson nolanlawson deleted the nolan/inline-iterator branch February 23, 2022 18:06
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.

[Template compiler] Inline iterators allow setting a key to an index
2 participants