2024-10-26 10:40:42 +02:00
|
|
|
;;; Copyright (C) 2024 David Thompson <dave@spritely.institute>
|
|
|
|
;;;
|
|
|
|
;;; Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
;;; you may not use this file except in compliance with the License.
|
|
|
|
;;; You may obtain a copy of the License at
|
|
|
|
;;;
|
|
|
|
;;; http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
;;;
|
|
|
|
;;; Unless required by applicable law or agreed to in writing, software
|
|
|
|
;;; distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
;;; See the License for the specific language governing permissions and
|
|
|
|
;;; limitations under the License.
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
;;;
|
|
|
|
;;; Element bindings.
|
|
|
|
;;;
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
(define-module (dom element)
|
|
|
|
#:use-module (hoot ffi)
|
|
|
|
#:export (element-value
|
|
|
|
set-element-value!
|
|
|
|
element-width set-element-width!
|
|
|
|
element-height set-element-height!
|
|
|
|
append-child!
|
|
|
|
remove!
|
|
|
|
replace-with!
|
|
|
|
set-attribute!
|
|
|
|
remove-attribute!
|
2024-10-27 13:34:16 +01:00
|
|
|
clone-element
|
|
|
|
element-checked?
|
|
|
|
set-element-checked!))
|
2024-10-26 10:40:42 +02:00
|
|
|
|
|
|
|
(define-foreign element-value
|
|
|
|
"element" "value"
|
|
|
|
(ref extern) -> (ref string))
|
|
|
|
(define-foreign set-element-value!
|
|
|
|
"element" "setValue"
|
|
|
|
(ref extern) (ref string) -> none)
|
|
|
|
(define-foreign element-width
|
|
|
|
"element" "width"
|
|
|
|
(ref extern) -> i32)
|
|
|
|
(define-foreign element-height
|
|
|
|
"element" "height"
|
|
|
|
(ref extern) -> i32)
|
|
|
|
(define-foreign set-element-width!
|
|
|
|
"element" "setWidth"
|
|
|
|
(ref extern) i32 -> none)
|
|
|
|
(define-foreign set-element-height!
|
|
|
|
"element" "setHeight"
|
|
|
|
(ref extern) i32 -> none)
|
|
|
|
(define-foreign append-child!
|
|
|
|
"element" "appendChild"
|
|
|
|
(ref extern) (ref extern) -> (ref extern))
|
|
|
|
(define-foreign remove!
|
|
|
|
"element" "remove"
|
|
|
|
(ref extern) -> none)
|
|
|
|
(define-foreign replace-with!
|
|
|
|
"element" "replaceWith"
|
|
|
|
(ref extern) (ref extern) -> none)
|
2024-10-27 13:34:16 +01:00
|
|
|
(define-foreign %set-attribute!
|
2024-10-26 10:40:42 +02:00
|
|
|
"element" "setAttribute"
|
|
|
|
(ref extern) (ref string) (ref string) -> none)
|
|
|
|
(define-foreign remove-attribute!
|
|
|
|
"element" "removeAttribute"
|
|
|
|
(ref extern) (ref string) -> none)
|
|
|
|
(define-foreign clone-element
|
|
|
|
"element" "clone"
|
|
|
|
(ref extern) -> (ref extern))
|
2024-10-27 13:34:16 +01:00
|
|
|
|
|
|
|
(define-foreign %element-checked?
|
|
|
|
"element" "checked"
|
|
|
|
(ref null extern) -> i32)
|
|
|
|
(define (element-checked? elem)
|
|
|
|
(= (%element-checked? elem) 1))
|
|
|
|
|
|
|
|
(define-foreign set-element-checked!
|
|
|
|
"element" "setChecked"
|
|
|
|
(ref null extern) i32 -> none)
|
|
|
|
(define (set-attribute! elem name val)
|
|
|
|
(if (string=? name "checked")
|
|
|
|
(set-element-checked! elem (if val 1 0))
|
|
|
|
(%set-attribute! elem name val)))
|