Browse Source

#791 fix display of text `0`

Falko Schindler 2 years ago
parent
commit
c4f18b6fc3
2 changed files with 2 additions and 2 deletions
  1. 1 1
      nicegui/element.py
  2. 1 1
      nicegui/templates/index.html

+ 1 - 1
nicegui/element.py

@@ -41,7 +41,7 @@ class Element(Visibility):
         self._style: Dict[str, str] = {}
         self._props: Dict[str, Any] = {}
         self._event_listeners: Dict[str, EventListener] = {}
-        self._text: str = ''
+        self._text: Optional[str] = None
         self.slots: Dict[str, Slot] = {}
         self.default_slot = self.add_slot('default')
 

+ 1 - 1
nicegui/templates/index.html

@@ -104,7 +104,7 @@
               }));
             }
             const children = data.ids.map(id => renderRecursively(elements, id));
-            if (name === 'default' && element.text) {
+            if (name === 'default' && element.text !== null) {
               children.unshift(element.text);
             }
             return [ ...rendered, ...children]