rabbibotton / clog

CLOG - The Common Lisp Omnificent GUI
Other
1.48k stars 101 forks source link

Bug: Unable to setf text-value of a clog element #230

Closed imadhui closed 1 year ago

imadhui commented 1 year ago

This is the code to reproduce the bug:

(ql:quickload :clog)

(in-package :clog-user)

(clog-repl)

(defparameter *div* (create-div *body* :content ""))

(setf (text-value *div*) "d")

Nothing shows up on the browser. The browser console shows an error. This is from safari.

image

The bug is also reproducible on chrome.

imadhui commented 1 year ago

This only happens when content is "" in create-div. When the content is set to, say "d", it works properly.

imadhui commented 1 year ago

This bug has nothing to do with clog-repl. I discovered it when I was working on my app.

rabbibotton commented 1 year ago

Is a bug with HTML itself. Creating a div with no content produces a div without a text node (technically not part of html). I'll give you some work arounds soon

rabbibotton commented 1 year ago

So the official way to place text in a DIV with no text node is

  1. Use text (or inner-html) instead of text-value (text-value won't replace the any html if exists with in the div, text will erase anything in the div. keep that in mind)
  2. Create it with some text and then replace the text with ""
  3. Use place-text-inside-bottom-of or place-text-inside-top-of that create new text nodes.