Use dataset setters instead of setAttribute.

This commit is contained in:
Mayhem 2013-07-14 18:51:02 +02:00
parent d252aacf4f
commit ddbec61e1b
8 changed files with 17 additions and 15 deletions

View File

@ -206,7 +206,7 @@ Filter =
el = $.el 'a', el = $.el 'a',
href: 'javascript:;' href: 'javascript:;'
textContent: text textContent: text
el.setAttribute 'data-type', type el.dataset.type = type
$.on el, 'click', Filter.menu.makeFilter $.on el, 'click', Filter.menu.makeFilter
return { return {

View File

@ -96,7 +96,7 @@ ThreadHiding =
className: "#{type}-thread-button" className: "#{type}-thread-button"
innerHTML: "<span>[&nbsp;#{if type is 'hide' then '-' else '+'}&nbsp;]</span>" innerHTML: "<span>[&nbsp;#{if type is 'hide' then '-' else '+'}&nbsp;]</span>"
href: 'javascript:;' href: 'javascript:;'
a.setAttribute 'data-fullid', thread.fullID a.dataset.fullid = thread.fullID
$.on a, 'click', ThreadHiding.toggle $.on a, 'click', ThreadHiding.toggle
a a

View File

@ -60,4 +60,4 @@ class Clone extends Post
@isDead = true if origin.isDead @isDead = true if origin.isDead
@isClone = true @isClone = true
index = origin.clones.push(@) - 1 index = origin.clones.push(@) - 1
root.setAttribute 'data-clone', index root.dataset.clone = index

View File

@ -140,7 +140,7 @@ Header =
a.textContent a.textContent
if m = t.match /-(index|catalog)/ if m = t.match /-(index|catalog)/
a.setAttribute 'data-only', m[1] a.dataset.only = m[1]
a.href = "//boards.4chan.org/#{board}/" a.href = "//boards.4chan.org/#{board}/"
a.href += 'catalog' if m[1] is 'catalog' a.href += 'catalog' if m[1] is 'catalog'

View File

@ -194,5 +194,5 @@ class Post
rmClone: (index) -> rmClone: (index) ->
@clones.splice index, 1 @clones.splice index, 1
for clone in @clones[index..] for clone in @clones[index..]
clone.nodes.root.setAttribute 'data-clone', index++ clone.nodes.root.dataset.clone = index++
return return

View File

@ -458,9 +458,9 @@ Settings =
td.innerHTML = '<select></select>' td.innerHTML = '<select></select>'
select = td.firstElementChild select = td.firstElementChild
unless select.disabled = length is 1 unless select.disabled = length is 1
# XXX GM can't into datasets $.extend select.dataset,
select.setAttribute 'data-boardid', boardID boardid: boardID
select.setAttribute 'data-type', type type: type
$.on select, 'change', Settings.saveSelectedArchive $.on select, 'change', Settings.saveSelectedArchive
$.add select, options $.add select, options
else else

View File

@ -13,7 +13,7 @@ ImageHover =
el = $.el 'img', el = $.el 'img',
id: 'ihover' id: 'ihover'
src: post.file.URL src: post.file.URL
el.setAttribute 'data-fullid', post.fullID el.dataset.fullid = post.fullID
$.add d.body, el $.add d.body, el
UI.hover UI.hover
root: @ root: @

View File

@ -44,9 +44,10 @@ Quotify =
className: 'quotelink deadlink' className: 'quotelink deadlink'
target: '_blank' target: '_blank'
textContent: "#{quote}\u00A0(Dead)" textContent: "#{quote}\u00A0(Dead)"
a.setAttribute 'data-boardid', boardID $.extend a.dataset,
a.setAttribute 'data-threadid', post.thread.ID boardid: boardID
a.setAttribute 'data-postid', postID threadid: post.thread.ID
postid: postID
else if redirect = Redirect.to 'thread', {boardID, threadID: 0, postID} else if redirect = Redirect.to 'thread', {boardID, threadID: 0, postID}
# Replace the .deadlink span if we can redirect. # Replace the .deadlink span if we can redirect.
a = $.el 'a', a = $.el 'a',
@ -56,9 +57,10 @@ Quotify =
textContent: "#{quote}\u00A0(Dead)" textContent: "#{quote}\u00A0(Dead)"
if Redirect.to 'post', {boardID, postID} if Redirect.to 'post', {boardID, postID}
# Make it function as a normal quote if we can fetch the post. # Make it function as a normal quote if we can fetch the post.
$.addClass a, 'quotelink' $.addClass a, 'quotelink'
a.setAttribute 'data-boardid', boardID $.extend a.dataset,
a.setAttribute 'data-postid', postID boardid: boardID
postid: postID
unless quoteID in @quotes unless quoteID in @quotes
@quotes.push quoteID @quotes.push quoteID