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

Proof of slot mixin test having wrong assumption about polyfill being loaded #2357

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aghArdeshir
Copy link
Contributor

@aghArdeshir aghArdeshir commented Aug 30, 2024

This is as a prof for #2358
This PR:

  • Removes every other test in the SlotMixin test file
  • Removes the polyfill from web-test-runner.config
  • Filters only the tests in the core folder so we see the proof faster

This test fails when polyfill is not loaded, but passes as soon as you add back the polyfill in the web-test-runner.config file. But the test title implies that it should run without the polyfill.

Copy link

changeset-bot bot commented Aug 30, 2024

⚠️ No Changeset found

Latest commit: 805a2e1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@aghArdeshir
Copy link
Contributor Author

Here is the non-test-environment of the same code with the same error. Create a test.html file in the root folder of the liom repo, put these in, and do npx parcel test.html

<!doctype html>
<html>
  <body>
    <!-- UNCOMMENT SCRIPT BELOW TO SEE THE MAGIC -->
    <!-- <script src="/node_modules/@webcomponents/scoped-custom-element-registry/scoped-custom-element-registry.min.js"></script> -->
    <script type="module">
      // @ts-nocheck
      /* eslint-disable */

      import { LitElement, html } from 'lit';
      import { ScopedElementsMixin } from '@open-wc/scoped-elements/lit-element.js';
      import { SlotMixin } from './packages/ui/components/core/src/SlotMixin.js';

      let defineCECounter = 0;
      function defineCE(klass) {
        const tag = `test-${defineCECounter}`;
        customElements.define(tag, klass);
        defineCECounter += 1;
        return tag;
      }

      ShadowRoot.prototype.createElement = null;
      class ScopedEl extends LitElement {}

      const tagName = defineCE(
        class extends ScopedElementsMixin(SlotMixin(LitElement)) {
          static get scopedElements() {
            return {
              // @ts-expect-error
              ...super.scopedElements,
              'scoped-el': ScopedEl,
            };
          }

          get slots() {
            return {
              ...super.slots,
              template: () => html`<scoped-el></scoped-el>`,
            };
          }

          render() {
            return html`<slot name="template"></slot>`;
          }
        },
      );

      const renderTarget = document.createElement('div');
      const el = document.createElement(tagName);

      document.body.appendChild(renderTarget);
      renderTarget.appendChild(el);

      document.body.removeChild(renderTarget);
    </script>
  </body>
</html>

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