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

feat(compiler): perform automatic key insertion in more situations #5594

Merged
merged 1 commit into from
Apr 5, 2024

Commits on Apr 5, 2024

  1. feat(compiler): perform automatic key insertion in more situations

    This expands the scope of the automatic key insertion feature that was
    added in #5143. Previously the feature stopped at the border of any
    `JsxExpression` syntax node (a bit of arbitrary JavaScript wrapped in
    curly braces and then inserted into JSX) so that if you were doing
    something like:
    
    ```tsx
    <div>{ someCondition && <span>when condition is true</span>}</div>
    ```
    
    the compiler would insert a key into the `<div>` syntax tree node but
    _not_ the node for the `<span>`. We did this to just be a bit cautious
    with the feature because there are a lot of different things that could
    be going on within a `JsxExpression` node, and some things which could
    be written within curly braces which would not be safe to transform,
    such as the following:
    
    ```tsx
    <div>{ xs.map(x => <span>{ x }</span>) }</div>
    ```
    
    We wouldn't want to insert a key into the `<span>` syntax tree node
    because that would result in the dynamically generated `<span>` tags
    always having the same key attributes.
    
    That said, there are some situations where it is safe to insert a key,
    such as the `condition || <some-tag />` case shown above. This change
    adds support for inserting keys in those situations.
    
    STENCIL-1120
    alicewriteswrongs committed Apr 5, 2024
    Configuration menu
    Copy the full SHA
    f1b3faa View commit details
    Browse the repository at this point in the history