select

Better select widgets in vanilla javascript.  https://p.ce9e.org/select/demo/
git clone https://git.ce9e.org/select.git

commit
5592207a144b9f879c14cf5268df25bfcbed2a76
parent
0482ec8f8bfb3c70506c9295af1c64e2aae3d1ae
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2023-08-11 15:02
refactor: reset paddingTop first

Diffstat

M values.js 8 ++------

1 files changed, 2 insertions, 6 deletions


diff --git a/values.js b/values.js

@@ -20,15 +20,11 @@ export class Values {
   20    20 	}
   21    21 
   22    22 	updateSize() {
   -1    23 		this.input.style.paddingTop = null;
   23    24 		this.input.style.lineHeight = null;
   24    25 		var style = getComputedStyle(this.input);
   25    26 
   26    -1 		// We may already have changed paddingTop, so we assume that original
   27    -1 		// paddingTop and paddingBottom are the same
   28    -1 		var paddingTop = parseFloat(style.paddingBottom);
   29    -1 
   30    27 		this.el.style.inset = style.padding;
   31    -1 		this.el.style.top = `${paddingTop}px`;
   32    28 		this.el.style.borderWidth = style.borderWidth;
   33    29 
   34    30 		var n = this.el.children.length;
@@ -44,6 +40,7 @@ export class Values {
   44    40 			this.measure.style.font = style.font;
   45    41 			var text = this.measure.getBoundingClientRect();
   46    42 
   -1    43 			var paddingTop = parseFloat(style.paddingTop);
   47    44 			var lineHeight = style.lineHeight === 'normal'
   48    45 				? text.height
   49    46 				: parseFloat(style.lineHeight);
@@ -60,7 +57,6 @@ export class Values {
   60    57 				this.input.style.textIndent = '0';
   61    58 			}
   62    59 		} else {
   63    -1 			this.input.style.paddingTop = `${paddingTop}px`;
   64    60 			this.input.style.textIndent = '0';
   65    61 		}
   66    62 	}