Add $.rmAll.
Up to 60 000 times faster than innerHTML = null! (wtf) Crazy stuff.
This commit is contained in:
parent
f753ed1db6
commit
0ff0b14d27
@ -102,6 +102,11 @@ $.extend $,
|
|||||||
(el) -> el.remove()
|
(el) -> el.remove()
|
||||||
else
|
else
|
||||||
(el) -> el.parentNode?.removeChild el
|
(el) -> el.parentNode?.removeChild el
|
||||||
|
rmAll: (el) ->
|
||||||
|
# jsperf.com/emptify-element
|
||||||
|
while node = el.firstChild
|
||||||
|
$.rm node
|
||||||
|
return
|
||||||
tn: (s) ->
|
tn: (s) ->
|
||||||
d.createTextNode s
|
d.createTextNode s
|
||||||
nodes: (nodes) ->
|
nodes: (nodes) ->
|
||||||
|
|||||||
@ -86,7 +86,7 @@ Header =
|
|||||||
|
|
||||||
generateBoardList: (text) ->
|
generateBoardList: (text) ->
|
||||||
list = $ '#custom-board-list', Header.bar
|
list = $ '#custom-board-list', Header.bar
|
||||||
list.innerHTML = null
|
$.rmAll list
|
||||||
return unless text
|
return unless text
|
||||||
as = $$('#full-board-list a', Header.bar)[0...-2] # ignore the Settings and Home links
|
as = $$('#full-board-list a', Header.bar)[0...-2] # ignore the Settings and Home links
|
||||||
nodes = text.match(/[\w@]+(-(all|title|full|index|catalog|text:"[^"]+"))*|[^\w@]+/g).map (t) ->
|
nodes = text.match(/[\w@]+(-(all|title|full|index|catalog|text:"[^"]+"))*|[^\w@]+/g).map (t) ->
|
||||||
@ -358,7 +358,7 @@ Settings =
|
|||||||
$.rmClass selected, 'tab-selected'
|
$.rmClass selected, 'tab-selected'
|
||||||
$.addClass $(".tab-#{@hyphenatedTitle}", Settings.dialog), 'tab-selected'
|
$.addClass $(".tab-#{@hyphenatedTitle}", Settings.dialog), 'tab-selected'
|
||||||
section = $ 'section', Settings.dialog
|
section = $ 'section', Settings.dialog
|
||||||
section.innerHTML = null
|
$.rmAll section
|
||||||
section.className = "section-#{@hyphenatedTitle}"
|
section.className = "section-#{@hyphenatedTitle}"
|
||||||
@open section, g
|
@open section, g
|
||||||
section.scrollTop = 0
|
section.scrollTop = 0
|
||||||
@ -444,7 +444,7 @@ Settings =
|
|||||||
return
|
return
|
||||||
# XXX Firefox won't let us download automatically.
|
# XXX Firefox won't let us download automatically.
|
||||||
p = $ '.imp-exp-result', Settings.dialog
|
p = $ '.imp-exp-result', Settings.dialog
|
||||||
p.innerHTML = null
|
$.rmAll p
|
||||||
$.add p, a
|
$.add p, a
|
||||||
import: ->
|
import: ->
|
||||||
@nextElementSibling.click()
|
@nextElementSibling.click()
|
||||||
@ -566,7 +566,7 @@ Settings =
|
|||||||
selectFilter: ->
|
selectFilter: ->
|
||||||
div = @nextElementSibling
|
div = @nextElementSibling
|
||||||
if (name = @value) isnt 'guide'
|
if (name = @value) isnt 'guide'
|
||||||
div.innerHTML = null
|
$.rmAll div
|
||||||
ta = $.el 'textarea',
|
ta = $.el 'textarea',
|
||||||
name: name
|
name: name
|
||||||
className: 'field'
|
className: 'field'
|
||||||
@ -2452,10 +2452,10 @@ Get =
|
|||||||
|
|
||||||
# Get rid of the side arrows.
|
# Get rid of the side arrows.
|
||||||
{nodes} = clone
|
{nodes} = clone
|
||||||
nodes.root.innerHTML = null
|
$.rmAll nodes.root
|
||||||
$.add nodes.root, nodes.post
|
$.add nodes.root, nodes.post
|
||||||
|
|
||||||
root.innerHTML = null
|
$.rmAll root
|
||||||
$.add root, nodes.root
|
$.add root, nodes.root
|
||||||
fetchedPost: (req, boardID, threadID, postID, root, context) ->
|
fetchedPost: (req, boardID, threadID, postID, root, context) ->
|
||||||
# In case of multiple callbacks for the same request,
|
# In case of multiple callbacks for the same request,
|
||||||
@ -4276,7 +4276,7 @@ ThreadWatcher =
|
|||||||
$.add div, [x, $.tn(' '), link]
|
$.add div, [x, $.tn(' '), link]
|
||||||
nodes.push div
|
nodes.push div
|
||||||
|
|
||||||
ThreadWatcher.dialog.innerHTML = ''
|
$.rmAll ThreadWatcher.dialog
|
||||||
$.add ThreadWatcher.dialog, nodes
|
$.add ThreadWatcher.dialog, nodes
|
||||||
|
|
||||||
watched = watched[g.BOARD] or {}
|
watched = watched[g.BOARD] or {}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user