Comments (13)
This is actually kind of doubly worse, because the exact same issue is occuring with Script tags, but these seem to be replaced before the browser starts executing
<script context="module"></script>
<script>export let scriptStr;
export let id = undefined;
</script>
<svelte:element this={"script"} {id}>{@html scriptStr}</svelte:element>
from builder.
@samijaber awesome looks to be working now
from builder.
@samijaber do you have any ETA for when this might get fixed? It's probably affecting every svelte site using builder.io and preventing our organisations projects from adopting it.
Thank you in advance
from builder.
@samijaber happy to attempt giving this a PR if you can point me in the right direction
from builder.
Hey @AlbertMarashi, thanks for filing this bug. We are still looking into the issue and will report back when we have an update.
from builder.
@AlbertMarashi We fixed a styling bug in the latest SDK: v0.6.3
I believe it should fix your issue. Could you test it and let me know?
from builder.
Hi @samijaber
No unfortunately it did not fix the issue the issue arises from this mitosis component being improperly converted to Svelte code
The output of the component looks like this:
<script context="module"></script>
<script>export let styles;
export let id = undefined;
</script>
<svelte:element this={"sty" + "le"} {id}>{@html styles}</svelte:element>
The particular issue is this section {@html styles}
- Svelte is adding a HTML comment inside the CSS which is not valid CSS and breaks parsing.
The reason for this I assume is that svelte expects the
@html
to be rendering HTML and not CSS, and uses these comments to manage hydration (removing and adding HTML nodes between the inserted<!-- HTML_TAG_START -->
and comment nodes
There's a few ways to correctly approach this in svelte:
<script>
export let styles;
export let id = undefined;
</script>
{@html `<style id="${id}">${styles}</style>`}
Or:
<script>
export let styles;
export let id = undefined;
$: style_tag = `<style id="${id}">${styles}</style>`;
</script>
{@html style_tag}
Or
<script>
export let styles;
export let id = undefined;
</script>
<svelte:element this="style" {id}>{styles}</svelte:element>
from builder.
sveltejs/svelte#9341 I created an issue for this in Svelte but I believe this is a mitosis bug rather than a Svelte bug (although svelte should be warning about this or something)
from builder.
here's an example of the approach @AlbertMarashi mentioned above https://svelte.dev/repl/0c0942ba74b74d82a2f19c024053775a?version=4.2.2
Note: to ensure svelte preprocess does not pick up the style tag, it also has to be broken up/escaped in string literals, there are several ways to do this, eg the + concatenation in the original mitosis output or putting parts of it in a template expression.
from builder.
And maybe even more important:
Svelte does not sanitize expressions before injecting HTML. If the data comes from an untrusted source, you must sanitize it, or you are exposing your users to an XSS vulnerability.
https://svelte.dev/docs/special-tags#html
If mitosis emits code that allows untrustred/unescaped content in script or style tags this way, it should be documented.
from builder.
@samijaber this seems to be like a major show stopper from anyone seriously adopting builder.io for SvelteKit websites, having FOUC is a relatively large SEO & accessibility issue, not to mention this issue is also prevalent in <script>
tags because it uses a similar mitosis component
from builder.
@AlbertMarashi we have found the fix and are doing some final testing. A new version without the issue will be released very soon.
from builder.
Version 0.6.4 of the Svelte SDK should have a fix for the FOUC. SSR'd content should now have styles rendering properly.
We added a bunch of testing that shows styles working. I am going to mark this issue as closed, but feel free to comment/reopen if you see otherwise.
from builder.
Related Issues (20)
- [nuxt] Unknown file extension ".css" HOT 10
- [Vue3] TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".css" HOT 1
- cannot import schema via CLI HOT 2
- Nuxt Build fails for catch-all page (symbol has already been declared) HOT 2
- {all : unset} taking higher specificity HOT 2
- Error: Cannot find module 'isolated-vm' HOT 7
- TypeError: The specifier “@builder.io/sdk-vue” was a bare specifier, but was not remapped to anything. HOT 8
- BlocksWrapper component adds unnecessary div & styling creating CSS issues HOT 1
- Upgrading `@builder.io/sdk` to 2.2.1 breaks build HOT 1
- Upgrade isolated-vm version to latest version HOT 4
- `SIGSEGV` panic on Node.js 20 with `@builder.io/react` HOT 2
- Key option is not correctly forwarded in builder.getAll HOT 2
- Builder SDK Vue breaks after 0.12.4 (properties of null (reading 'isCE') HOT 2
- defineProps macro in vue 3 with TS (custom components) HOT 1
- `@builder.io/sdk-react-native` fails to render due to rendering a `div` in `DynamicRenderer` HOT 7
- How to give just simple array as prop HOT 2
- `$elemMatch` operator does not work in the new SDK HOT 5
- Types broke in Vue SDK after 0.12.8 HOT 3
- Is it possible to have dynamically created pages? HOT 1
- see image preview instead cloud icon HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from builder.