Commit db575953239b738e0d908ed0e7005bc4aa45d14c
fixing some nully undefined logic
mix irving committed on 2/20/2018, 2:57:58 AMParent: f282bf4a9ac0e60ba0de219dad5704df86000ec5
Files changed
app/html/scroller.js | changed |
app/page/thread.js | changed |
app/html/scroller.js | ||
---|---|---|
@@ -42,22 +42,23 @@ | ||
42 | 42 … | } |
43 | 43 … | } |
44 | 44 … | } |
45 | 45 … | |
46 … | + return function scroll (d) { | |
47 … | + selectChild((!curMsgEl || d === 'first') ? container.firstChild | |
48 … | + : d < 0 ? curMsgEl.previousElementSibling || container.firstChild | |
49 … | + : d > 0 ? curMsgEl.nextElementSibling || container.lastChild | |
50 … | + : curMsgEl) | |
51 … | + | |
52 … | + return curMsgEl | |
53 … | + } | |
54 … | + | |
46 | 55 … | function selectChild (el) { |
47 | 56 … | if (!el) { return } |
48 | 57 … | |
49 | - if (!el.scrollIntoViewIfNeeded && !el.scrollIntoView) debugger | |
58 … | + if (!el.scrollIntoViewIfNeeded && !el.scrollIntoView) return | |
50 | 59 … | ;(el.scrollIntoViewIfNeeded || el.scrollIntoView).call(el) |
51 | 60 … | el.focus() |
52 | 61 … | curMsgEl = el |
53 | 62 … | } |
54 | 63 … | |
55 | - return function scroll (d) { | |
56 | - selectChild((!curMsgEl || d === 'first') ? container.firstChild | |
57 | - : d < 0 ? curMsgEl.previousElementSibling || container.firstChild | |
58 | - : d > 0 ? curMsgEl.nextElementSibling || container.lastChild | |
59 | - : curMsgEl) | |
60 | - | |
61 | - return curMsgEl | |
62 | - } | |
63 | 64 … | } |
app/page/thread.js | ||
---|---|---|
@@ -101,9 +101,9 @@ | ||
101 | 101 … | if (!tabs.currentPage().scroll) return setTimeout(locateKey, 200) |
102 | 102 … | |
103 | 103 … | tabs.currentPage().scroll('first') |
104 | 104 … | const msg = tabs.currentPage().querySelector(`[data-id='${id}']`) |
105 | - if (msg === undefined) return setTimeout(locateKey, 200) | |
105 … | + if (!msg) return setTimeout(locateKey, 200) | |
106 | 106 … | |
107 | 107 … | ;(msg.scrollIntoViewIfNeeded || msg.scrollIntoView).call(msg) |
108 | 108 … | msg.focus() |
109 | 109 … | } |
Built with git-ssb-web