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

Ensure original named slot tags are retained when not using shadow root. #1

Closed
wants to merge 3 commits into from

Conversation

patricknelson
Copy link
Owner

Setup to run unit tests.

…ing shadow root. Only "unwrap" (i.e. from the host tag) when in the default slot. Including ignore of .idea/ files (JetBrains) and enforcing repo-specific whitespace rules (differs from my specific IDE settings)
@crisward
Copy link

crisward commented Jun 2, 2023

Any chance you can remove the yarn.lock, not sure we need this with package-lock.json?

Otherwise looks good.

The tests use snowpack, which has since died. The only way to get the tests working for me is to do

nvm use 14
npm ci
npm test

It sounds like svelte 4 may make svelte-tag obsolete, otherwise I'd look to update the test runner.

@patricknelson
Copy link
Owner Author

patricknelson commented Jun 2, 2023

Oh shoot! That's my fault, sorry about that. Comedy of errors. I ended up using yarn to link the package instead of npm since it was acting up (complaining about an "Unsupported engine", screenshot below) so I used yarn link to connect it to my project for testing (which resulted in yarn.lock).

And yeah just tried that (v14) and same error. I'm convinced it's an issue with the package and the fact that I'm on WSL2. Trying to launch a full blown GUI-based browser like that is a bit Rube Goldbergian IMHO. I wonder if Vitest would be better/faster at this (probably worth a shot later).

image

It sounds like svelte 4 may make svelte-tag obsolete, otherwise I'd look to update the test runner.

Maybe! I'm not sure. The reason I say that is because so far, svelte-tag seems to be working far better than Svelte v4. That said, I totally understand it's a WIP, however, there's a good argument for implementing it via a plugin like this. The reason why is because the core library is complicated. It's also far more difficult to reason about. It took me a long time to get setup and running with Svelte for development, then to reason about the issues, submit those issues (e.g. see my issues here, don't want to link directly to prevent cross referencing). On the flip side, I found svelte-tag to be far easier to get up and running, experiment with and etc. Also, we have to hope that the maintainers are willing/able to support things like HMR natively for custom elements, which I'm not certain about (since that's apparently not currently happening in v3 and v4, yet). I may submit an issue for that later. If you see in one of my issues (relating to customElements.define() compatibility), it turns out that I accidentally got HMR for free but then when I realized there was a "right" (blessed) way from the maintainers (i.e. Component.element) it didn't work with HMR 😞

Plus the upside to svelte-tag is that I'm already using it in production at ebayinc.com so I'm invested in finding a solution to the solving problems I encounter.

@patricknelson
Copy link
Owner Author

patricknelson commented Jun 3, 2023

p.s. on the topic of unit testing, I've got a single experimental test up and running using vitest 😄 See:

Works on my machine locally as well as in Github's CI/Actions, so... should make it far easier for me to contribute and iterate since I can run the tests locally. Not sure about shadow DOM yet though (going to try that soon).

Edit: Thankfully it appears shadow DOM is working as expected! 👍

@patricknelson
Copy link
Owner Author

Alright, converted the repo over to using Vitest, see crisward/svelte-tag#14 😅

Determined to get that up and running so I can start cranking through some of the other issues in the repo (including the one relating to nested slots... got some ideas...).

@patricknelson
Copy link
Owner Author

Closing since crisward/svelte-tag#13 is merged.

@patricknelson patricknelson deleted the issue-12-dont-unwrap-named-slots branch June 3, 2023 20:56
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.

2 participants