Skip to content

Commit

Permalink
Reduce usage of String#createElement
Browse files Browse the repository at this point in the history
  • Loading branch information
nanaya committed Feb 18, 2024
1 parent 5f98ea3 commit 0011adb
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions app/javascript/src/classes/tag_completion_box.coffee
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
createCompletionBox = ->
ret = document.createElement('div')
ret.className = 'tag-completion-box'
ret.tabIndex = -1

types = document.createElement('ul')
types.className = 'color-tag-types'
ret.appendChild types

ret


export default class TagCompletionBox
constructor: (input_field) ->
@input_field = input_field
@last_value = @input_field.value

# Disable browser autocomplete.
@input_field.setAttribute 'autocomplete', 'off'
html = '<div class="tag-completion-box"><ul class="color-tag-types"></ul></div>'
div = html.createElement()
div.tabindex = -1
document.body.appendChild div
@completion_box = div
@completion_box = createCompletionBox()
document.body.appendChild @completion_box
document.on 'mousedown', (event) =>
if event.target.isParentNode(@input_field) or event.target.isParentNode(@completion_box)
return
Expand Down

0 comments on commit 0011adb

Please sign in to comment.