about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/css/layout.nim2
-rw-r--r--src/html/dom.nim4
-rw-r--r--test/layout/button-text.expected4
-rw-r--r--test/layout/button-text.html4
-rw-r--r--test/layout/white-space-pre-on-new-line-box-skips-lf-space.expected2
-rw-r--r--test/layout/white-space-pre-on-new-line-box-skips-lf-space.html2
6 files changed, 15 insertions, 3 deletions
diff --git a/src/css/layout.nim b/src/css/layout.nim
index 76b2378c..bb5f5f42 100644
--- a/src/css/layout.nim
+++ b/src/css/layout.nim
@@ -793,7 +793,7 @@ proc processWhitespace(ictx: var InlineContext; state: var InlineState;
   discard ictx.addWord(state)
   case state.box.computed{"white-space"}
   of WhitespaceNormal, WhitespaceNowrap:
-    if ictx.whitespacenum < 1:
+    if ictx.whitespacenum < 1 and ictx.lbstate.atoms.len > 0:
       ictx.whitespacenum = 1
       ictx.whitespaceFragment = state.box
       ictx.whitespaceIsLF = c == '\n'
diff --git a/src/html/dom.nim b/src/html/dom.nim
index 06193a98..c23ed6eb 100644
--- a/src/html/dom.nim
+++ b/src/html/dom.nim
@@ -2591,12 +2591,12 @@ func inputString*(input: HTMLInputElement): string =
   of itPassword:
     '*'.repeat(input.value.len).padToWidth(int(input.attrulgz(satSize).get(20)))
   of itReset:
-    if input.value != "":
+    if input.attrb(satValue):
       input.value
     else:
       "RESET"
   of itSubmit, itButton:
-    if input.value != "":
+    if input.attrb(satValue):
       input.value
     else:
       "SUBMIT"
diff --git a/test/layout/button-text.expected b/test/layout/button-text.expected
new file mode 100644
index 00000000..b0e9318e
--- /dev/null
+++ b/test/layout/button-text.expected
@@ -0,0 +1,4 @@
+[SUBMIT]
+[]
+[RESET]
+[]
diff --git a/test/layout/button-text.html b/test/layout/button-text.html
new file mode 100644
index 00000000..a379055b
--- /dev/null
+++ b/test/layout/button-text.html
@@ -0,0 +1,4 @@
+<input type=submit><br>
+<input type=submit value=><br>
+<input type=reset><br>
+<input type=reset value=><br>
diff --git a/test/layout/white-space-pre-on-new-line-box-skips-lf-space.expected b/test/layout/white-space-pre-on-new-line-box-skips-lf-space.expected
new file mode 100644
index 00000000..4deac755
--- /dev/null
+++ b/test/layout/white-space-pre-on-new-line-box-skips-lf-space.expected
@@ -0,0 +1,2 @@
+test
+test  test
diff --git a/test/layout/white-space-pre-on-new-line-box-skips-lf-space.html b/test/layout/white-space-pre-on-new-line-box-skips-lf-space.html
new file mode 100644
index 00000000..f4e030e0
--- /dev/null
+++ b/test/layout/white-space-pre-on-new-line-box-skips-lf-space.html
@@ -0,0 +1,2 @@
+ test<br>
+<div style="display: inline-block; white-space: pre">test </div> test