You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have this really simple problem I can't seem to figure out. I'm trying to use JavaScriptKit to create an element in the browsers DOM and set some CSS style on it:
import JavaScriptKit
let document = JSObject.global.document
var spanElem = document.createElement("span")
spanElem.innerText = "hello"
spanElem.style.backgroundColor = "yellow"
_ = document.body.appendChild(spanElem)
But it seems that the assignment to spanElem.style.backgroundColor doesn't have any effect. When I run this code (as main.swift), the <span> is created but its CSS style is unchanged. Reading style.backgroundColor from the browser console also shows nothing, but changing it from there works as expected:
I'm using carton 0.10.0, Swift swift-wasm-5.3.1-RELEASE, JavaScriptKit 0.10.1 and am testing with newest Chrome and Safari (with same results) on macOS 10.15.7.
I have this really simple problem I can't seem to figure out. I'm trying to use
JavaScriptKitto create an element in the browsers DOM and set some CSS style on it:But it seems that the assignment to
spanElem.style.backgroundColordoesn't have any effect. When I run this code (asmain.swift), the<span>is created but its CSS style is unchanged. Readingstyle.backgroundColorfrom the browser console also shows nothing, but changing it from there works as expected:I'm using carton 0.10.0, Swift swift-wasm-5.3.1-RELEASE, JavaScriptKit 0.10.1 and am testing with newest Chrome and Safari (with same results) on macOS 10.15.7.
What am I doing wrong here?