From bfca284232b5289075473243ab544cbb444741e3 Mon Sep 17 00:00:00 2001 From: "Andre A. Gomes" Date: Tue, 27 Feb 2024 16:11:24 +0200 Subject: [PATCH] renderer-script(add-stylesheet): Refactor. --- source/renderer-script.lisp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/source/renderer-script.lisp b/source/renderer-script.lisp index 23040514af6..b457be9c272 100644 --- a/source/renderer-script.lisp +++ b/source/renderer-script.lisp @@ -158,15 +158,13 @@ If `setf'-d to a list of two values -- set Y to `first' and X to `second' elemen (ps:chain result (slice 0 (ps:lisp limit))))) (export-always 'add-stylesheet) -(defun add-stylesheet (stylesheet-name style &optional (buffer (current-buffer))) - "Find/create a STYLESHEET-NAMEd element and set the STYLE as it's content." +(defun add-stylesheet (id style &optional (buffer (current-buffer))) + "Set STYLE of element featuring ID." (ps-eval :async t :buffer buffer - (unless (nyxt/ps:qs document (ps:lisp - (concatenate - 'string '(#\#) stylesheet-name))) + (unless (nyxt/ps:qs document (ps:lisp (str:concat "#" id))) (ps:try (ps:let ((style-element (ps:chain document (create-element "style")))) - (setf (ps:@ style-element id) (ps:lisp stylesheet-name)) + (setf (ps:@ style-element id) (ps:lisp id)) (ps:chain document head (append-child style-element)) (setf (ps:chain style-element inner-text) (ps:lisp style))) (:catch (error))))))