github.com/primecitizens/pcz/std@v0.2.1/plat/js/webext/dom/apis_js_wasm.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2023 The Prime Citizens 3 4 package dom 5 6 import ( 7 "github.com/primecitizens/pcz/std/ffi/js" 8 "github.com/primecitizens/pcz/std/plat/js/webext/dom/bindings" 9 ) 10 11 // HasFuncOpenOrClosedShadowRoot returns true if the function "WEBEXT.dom.openOrClosedShadowRoot" exists. 12 func HasFuncOpenOrClosedShadowRoot() bool { 13 return js.True == bindings.HasFuncOpenOrClosedShadowRoot() 14 } 15 16 // FuncOpenOrClosedShadowRoot returns the function "WEBEXT.dom.openOrClosedShadowRoot". 17 func FuncOpenOrClosedShadowRoot() (fn js.Func[func(element js.Any) js.Any]) { 18 bindings.FuncOpenOrClosedShadowRoot( 19 js.Pointer(&fn), 20 ) 21 return 22 } 23 24 // OpenOrClosedShadowRoot calls the function "WEBEXT.dom.openOrClosedShadowRoot" directly. 25 func OpenOrClosedShadowRoot(element js.Any) (ret js.Any) { 26 bindings.CallOpenOrClosedShadowRoot( 27 js.Pointer(&ret), 28 element.Ref(), 29 ) 30 31 return 32 } 33 34 // TryOpenOrClosedShadowRoot calls the function "WEBEXT.dom.openOrClosedShadowRoot" 35 // in a try/catch block and returns (_, err, ok = false) when it went through 36 // the catch clause. 37 func TryOpenOrClosedShadowRoot(element js.Any) (ret js.Any, exception js.Any, ok bool) { 38 ok = js.True == bindings.TryOpenOrClosedShadowRoot( 39 js.Pointer(&ret), js.Pointer(&exception), 40 element.Ref(), 41 ) 42 43 return 44 }