Using imported object for style attribute is reevaluated if other attribute uses updated signal
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 36.1k
- Forks
- 1.1k
- Avg merge
- 9h 18m
- Merged PRs (30d)
- 195
Description
Describe the bug
As the title, when using imported object for element style attribute, it is reevaluated if other attributes that use signal that is updated.
In this example a button element style uses an imported object called style which has background value of red.
export const style = {
"background": "red",
}
After the button is mounted then it's background is changed to blue via element style property.
import { style } from "./style"
// ...
onMount(() => {
buttonEl.style.background = 'blue'
})
return (
<button style={style} ... ref={buttonEl}>
{count()}
</button>
);
}
This button's aria-label attribute uses count signal which increments when clicked
const [count, setCount] = createSignal(1);
const increment = () => setCount(count() + 1);
let buttonEl;
onMount(() => {
buttonEl.style.background = 'blue'
})
return (
<button type="button" onClick={increment} aria-label={count().toString()} style={style} ref={buttonEl}>
{count()}
</button>
Your Example Website or App
https://playground.solidjs.com/anonymous/804fbf3b-2166-430f-ab99-c2b78770a1a6
Steps to Reproduce the Bug or Issue
- Click counter button
Expected behavior
For button's background color to remain blue, but after clicking button it resets red which is the background property from object style. If button style attribute uses style2 object, which is not imported then the button remains blue after updating count signal https://playground.solidjs.com/anonymous/efc28da8-a36c-42e5-b109-5d7b8a8c145e.
Screenshots or Videos
No response
Platform
- OS: macOS
- Browser: Chrome
- Version: 118.0.5993.117
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked Solid playground reproduction and compare the imported style object with the local style2 object while tracing JSX style attribute handling. Reproduce the counter update and identify why the imported object is reapplied. Done means the button remains blue after the count signal changes, without regressing the local-object behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100