_JS
_JS
SSolidJS
Created by _JS on 4/18/2024 in #support
onLoad attribute on a link tag in entry-server not running
I'm on @solidjs/start 0.7.7 and trying to add an onload="this.onload=null;this.rel='stylesheet'" on a link tag. The purpose is more widely explained here. Problem with this approach is that typescript keeps shouting Type 'string' is not assignable to type 'EventHandlerUnion<HTMLLinkElement, Event> | undefined'. So I rewrote the single liner above to the following:
<link
...
onLoad={function (this: HTMLLinkElement) {
console.log("I was run")
this.onload = null
this.rel = "stylesheet"
}}
/>
<link
...
onLoad={function (this: HTMLLinkElement) {
console.log("I was run")
this.onload = null
this.rel = "stylesheet"
}}
/>
And I don't see the console.log anywhere. I checked on the console tab, the terminal I ran "pnpm dev" on... nothing How should I handle this? I'd like to keep onload="this.onload=null;this.rel='stylesheet'", or accept any alternatives that work
10 replies
SSolidJS
Created by _JS on 2/1/2024 in #support
Imported unused variable for a directive seems awkward
I've went through the SolidJS tutorial (https://www.solidjs.com/tutorial/bindings_directives?solved) and saw that the imported directive function is just "hanging" there. I understand the bindings and directives are just syntactic sugar and behind the scenes its actually not "hanging". I was wondering if this is something that I should care about, should I be worried or is this going to be something that I should get used to? Preferably I'd be happy with something other than true && insertDirectiveFunctionName to get around it. Thank you for reading, any feedbacks are much appreciated!
9 replies