Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@justinfagnani
Copy link
Collaborator

Also fixes a directive-helpers test that was incorrectly constructing its test case.

I noticed that removePart() was almost the same as ChildPart.$_clear() with the exception of removing the start node. I also optimized ChildPart.$_clear() a little and noticed that the insertPart() test was wrong.

Also fixes a directive-helpers test that was incorrectly constructing its test case.
@changeset-bot
Copy link

changeset-bot bot commented Apr 14, 2025

πŸ¦‹ Changeset detected

Latest commit: bc5514d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
lit-html Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Apr 14, 2025

πŸ“Š Tachometer Benchmark Results

Summary

nop-update

  • this-change, tip-of-tree, previous-release: unsure πŸ” -5% - +14% (-0.59ms - +1.70ms)
    this-change vs tip-of-tree

render

  • this-change: 44.54ms - 57.17ms
  • this-change, tip-of-tree, previous-release: slower ❌ 1% - 7% (0.18ms - 1.27ms)
    this-change vs tip-of-tree
  • this-change, tip-of-tree, previous-release: unsure πŸ” -1% - +2% (-0.35ms - +0.62ms)
    this-change vs tip-of-tree
  • this-change, tip-of-tree, previous-release: unsure πŸ” -12% - +51% (-4.78ms - +23.16ms)
    this-change vs tip-of-tree

update

  • this-change: 512.68ms - 520.88ms
  • this-change, tip-of-tree, previous-release: unsure πŸ” -3% - +6% (-1.11ms - +2.19ms)
    this-change vs tip-of-tree
  • this-change, tip-of-tree, previous-release: unsure πŸ” -2% - +3% (-1.72ms - +2.24ms)
    this-change vs tip-of-tree
  • this-change, tip-of-tree, previous-release: unsure πŸ” -2% - +0% (-11.41ms - +2.09ms)
    this-change vs tip-of-tree

update-reflect

  • this-change: 504.35ms - 511.68ms
  • this-change, tip-of-tree, previous-release: unsure πŸ” -1% - +1% (-4.60ms - +4.43ms)
    this-change vs tip-of-tree

Results

this-change

render

VersionAvg timevs
44.54ms - 57.17ms-

update

VersionAvg timevs
512.68ms - 520.88ms-

update-reflect

VersionAvg timevs
504.35ms - 511.68ms-
this-change, tip-of-tree, previous-release

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
19.18ms - 19.89ms-slower ❌
1% - 7%
0.18ms - 1.27ms
unsure πŸ”
-1% - +5%
-0.15ms - +0.96ms
tip-of-tree
tip-of-tree
18.39ms - 19.23msfaster βœ”
1% - 6%
0.18ms - 1.27ms
-unsure πŸ”
-5% - +1%
-0.92ms - +0.28ms
previous-release
previous-release
18.71ms - 19.55msunsure πŸ”
-5% - +1%
-0.96ms - +0.15ms
unsure πŸ”
-1% - +5%
-0.28ms - +0.92ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
38.23ms - 40.33ms-unsure πŸ”
-3% - +6%
-1.11ms - +2.19ms
unsure πŸ”
-2% - +6%
-0.68ms - +2.40ms
tip-of-tree
tip-of-tree
37.46ms - 40.01msunsure πŸ”
-6% - +3%
-2.19ms - +1.11ms
-unsure πŸ”
-4% - +5%
-1.39ms - +2.02ms
previous-release
previous-release
37.29ms - 39.55msunsure πŸ”
-6% - +2%
-2.40ms - +0.68ms
unsure πŸ”
-5% - +4%
-2.02ms - +1.39ms
-

nop-update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
12.36ms - 14.05ms-unsure πŸ”
-5% - +14%
-0.59ms - +1.70ms
unsure πŸ”
-4% - +15%
-0.46ms - +1.87ms
tip-of-tree
tip-of-tree
11.87ms - 13.42msunsure πŸ”
-13% - +4%
-1.70ms - +0.59ms
-unsure πŸ”
-8% - +10%
-0.97ms - +1.27ms
previous-release
previous-release
11.69ms - 13.30msunsure πŸ”
-14% - +3%
-1.87ms - +0.46ms
unsure πŸ”
-10% - +8%
-1.27ms - +0.97ms
-
this-change, tip-of-tree, previous-release

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
35.19ms - 35.92ms-unsure πŸ”
-1% - +2%
-0.35ms - +0.62ms
unsure πŸ”
-1% - +2%
-0.35ms - +0.62ms
tip-of-tree
tip-of-tree
35.10ms - 35.74msunsure πŸ”
-2% - +1%
-0.62ms - +0.35ms
-unsure πŸ”
-1% - +1%
-0.44ms - +0.45ms
previous-release
previous-release
35.11ms - 35.73msunsure πŸ”
-2% - +1%
-0.62ms - +0.35ms
unsure πŸ”
-1% - +1%
-0.45ms - +0.44ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
77.34ms - 80.06ms-unsure πŸ”
-2% - +3%
-1.72ms - +2.24ms
unsure πŸ”
-2% - +3%
-1.24ms - +2.56ms
tip-of-tree
tip-of-tree
77.00ms - 79.88msunsure πŸ”
-3% - +2%
-2.24ms - +1.72ms
-unsure πŸ”
-2% - +3%
-1.56ms - +2.36ms
previous-release
previous-release
76.71ms - 79.37msunsure πŸ”
-3% - +2%
-2.56ms - +1.24ms
unsure πŸ”
-3% - +2%
-2.36ms - +1.56ms
-
this-change, tip-of-tree, previous-release

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
46.68ms - 67.79ms-unsure πŸ”
-12% - +51%
-4.78ms - +23.16ms
unsure πŸ”
-25% - +29%
-13.83ms - +16.10ms
tip-of-tree
tip-of-tree
38.89ms - 57.19msunsure πŸ”
-38% - +6%
-23.16ms - +4.78ms
-unsure πŸ”
-37% - +9%
-22.06ms - +5.95ms
previous-release
previous-release
45.49ms - 66.70msunsure πŸ”
-28% - +24%
-16.10ms - +13.83ms
unsure πŸ”
-15% - +48%
-5.95ms - +22.06ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
511.63ms - 521.47ms-unsure πŸ”
-2% - +0%
-11.41ms - +2.09ms
unsure πŸ”
-2% - +1%
-8.50ms - +4.33ms
tip-of-tree
tip-of-tree
516.59ms - 525.82msunsure πŸ”
-0% - +2%
-2.09ms - +11.41ms
-unsure πŸ”
-1% - +2%
-3.61ms - +8.76ms
previous-release
previous-release
514.52ms - 522.75msunsure πŸ”
-1% - +2%
-4.33ms - +8.50ms
unsure πŸ”
-2% - +1%
-8.76ms - +3.61ms
-

update-reflect

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
523.29ms - 529.70ms-unsure πŸ”
-1% - +1%
-4.60ms - +4.43ms
unsure πŸ”
-1% - +1%
-3.54ms - +5.05ms
tip-of-tree
tip-of-tree
523.39ms - 529.77msunsure πŸ”
-1% - +1%
-4.43ms - +4.60ms
-unsure πŸ”
-1% - +1%
-3.44ms - +5.13ms
previous-release
previous-release
522.88ms - 528.60msunsure πŸ”
-1% - +1%
-5.05ms - +3.54ms
unsure πŸ”
-1% - +1%
-5.13ms - +3.44ms
-

tachometer-reporter-action v2 for Benchmarks

const childPart2 = insertPart(part, undefined);
const childPart1 = insertPart(part, undefined, childPart2);
const childPart2 = insertPart(part);
const childPart1 = insertPart(part, childPart2);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Previously the test mixed up the parameter for the refPart and the part to be inserted. Passing the third parameter meant that the second call wasn't making a new part.

@github-actions
Copy link
Contributor

github-actions bot commented Apr 14, 2025

The size of lit-html.js and lit-core.min.js are as expected.

@rictic
Copy link
Collaborator

rictic commented Apr 15, 2025

This passes all of Google's internal tests!

@justinfagnani
Copy link
Collaborator Author

Thanks for running the google3 tests, @rictic!

@justinfagnani justinfagnani requested a review from rictic April 15, 2025 21:04
@justinfagnani justinfagnani merged commit 43a3f4d into main Apr 15, 2025
9 checks passed
@justinfagnani justinfagnani deleted the remove-part-golf branch April 15, 2025 21:57
@jimfranke
Copy link

@justinfagnani It looks like this change causes some unforseen behaviour. When using the CustomElement below to reshuffle a list of items with varying length via the repeat directive by pressing the button, I see markers <!----> being added and never being removed within the ul element; resulting in hundreds of dangling markers. When reverting this PR everything seems to behave as expected.

Could you please verify? Thanks!

<!doctype html>
<html lang="en">

<head>
  <meta charset="utf-8" />
  <title>App</title>

  <script type="module">
    //*! Import 'html' and 'render' versions from this PR !*/
    
    // Import the latest 'repeat' directive
    import { repeat } from 'https://cdn.jsdelivr.net/npm/[email protected]/directives/repeat.js';

    const fruits = [{
        name: 'apple',
        text: '🍎'
      },
      {
        name: 'banana',
        text: '🍌'
      },
      {
        name: 'grapes',
        text: 'πŸ‡'
      },
      {
        name: 'pineapple',
        text: '🍍'
      },
      {
        name: 'peach',
        text: 'πŸ‘'
      },
      {
        name: 'cherry',
        text: 'πŸ’'
      },
      {
        name: 'greenapple',
        text: '🍏'
      },
      {
        name: 'melon',
        text: 'πŸ‰'
      },
      {
        name: 'strawberry',
        text: 'πŸ“'
      },
    ];

    customElements.define(
      'x-app',
      class App extends HTMLElement {
        #fruits = [...fruits];

        connectedCallback() {
          this.render();
        }

        shuffleFruits = () => {
          const size = Math.floor(Math.random() * fruits.length) + 1;

          this.#fruits = fruits.sort(() => Math.random() - 0.5).slice(-size);
          console.log(this.#fruits.concat());
          this.render();
        };

        render() {
          render(
            html`
          <main>
            <button @click=${this.shuffleFruits}>Shuffle Fruits</button>

            <ul>
              ${repeat(
                this.#fruits,
                fruit => fruit.name,
                fruit =>
                  html`<li>
                    <label>
                      <input name=${fruit.name} type="checkbox" />
                      ${fruit.name} - ${fruit.text}
                    </label>
                  </li>`,
              )}
            </ul>
          </main>
        `,
            this,
          );
        }
      },
    );
  </script>
</head>

<body>
  <x-app></x-app>
</body>

</html>

@justinfagnani
Copy link
Collaborator Author

@jimfranke since this PR is merged, can you open a new issue so we can be sure to track it?

@justinfagnani
Copy link
Collaborator Author

I do think I see the problem here. We need some more tests for repeat and directive helpers.

@jimfranke
Copy link

@jimfranke since this PR is merged, can you open a new issue so we can be sure to track it?

Thanks, sure! #5010

@lit-robot lit-robot mentioned this pull request Jul 11, 2025
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.

3 participants