Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Signal value update overwrites css-scope-inline style block of html #28

Open
@eboody

Description

@eboody

Description:

When usingpreact/signals-core and surreal's companion scriptcss-scope-inline, I encountered an issue where when updating the element's textContent the script and style blocks get overwritten. This only happens when I include astyle block in the element. Here is the code to reproduce the issue:

<script>letmySignal=signal("");</script>
<div>  sample text<script>{lettextElement=me();effect(()=>(textElement.textContent=mySignal.value));}</script><style>me {background-color: red;    }</style></div>

In this setup, when I change the value of the signal (mySignal.value = "some new text";), thescript andstyle blocks get overwritten.

However, if I get thefirstChild of thediv, this issue does not occur:

<div>  sample text<script>{lettextElement=me().firstChild;effect(()=>(textElement.textContent=mySignal.value));}</script><style>me {background-color: red;    }</style></div>

Steps to Reproduce:

1. Create a signal.2. Use the signal value to update the textContent of an element inside a div that has a nested style block.3. Observe that the script and style blocks within the div are overwritten when the signal's value changes.

Expected Behavior:

Thescript andstyle blocks of thediv should not be overwritten when updating itstextContent with the signal's value.

Actual Behavior:

Thescript andstyle blocks of thediv element are overwritten when the signal's value is updated.

Additional Context:

When loggingtextElement.textContent both inside and outside the effect, it consistently shows "sample text" as expected.

To includepreact/signals-core in your project you can use this html file which contains ascript tag and the compiledpreact/signals-core JS code:
https://github.com/eboody/app-template/blob/main/crates/services/web-server/src/templates/modules/signals.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp