History

Use parentNode instead of parentElement as the latter doesn't work on SVG elements in some browsers

Thibaut Courouble committed 9 years ago

Commit 53f666a1 parent eea75964 files · +17 −17Browse files

Unified · Split

4 files
  1. assets/javascripts/lib/page.coffee +1 −1
  2. assets/javascripts/lib/util.coffee +8 −8
  3. assets/javascripts/views/list/list_focus.coffee +6 −6
  4. assets/javascripts/views/list/list_fold.coffee +2 −2
assets/javascripts/lib/page.coffee+1−1
@@ -171,7 +171,7 @@ onclick = (event) -> · 170 unmodified lines
171171 return
172172
173173 link = event.target
174− link = link.parentElement while link and link.tagName isnt 'A'
174+ link = link.parentNode while link and link.tagName isnt 'A'
175175
176176 if link and not link.target and isSameOrigin(link.href)
177177 event.preventDefault()
assets/javascripts/lib/util.coffee+8−8
@@ -16,13 +16,13 @@ $.hasChild = (parent, el) -> · 15 unmodified lines
1616 while el
1717 return true if el is parent
1818 return if el is document.body
19− el = el.parentElement
19+ el = el.parentNode
2020
2121 $.closestLink = (el, parent = document.body) ->
2222 while el
2323 return el if el.tagName is 'A'
2424 return if el is parent
25− el = el.parentElement
25+ el = el.parentNode
2626
2727 #
2828 # Events
@@ -96,7 +96,7 @@ $.before = (el, value) -> · 67 unmodified lines
9696 if typeof value is 'string' or $.isCollection(value)
9797 value = buildFragment(value)
9898
99− el.parentElement.insertBefore(value, el)
99+ el.parentNode.insertBefore(value, el)
100100 return
101101
102102 $.after = (el, value) ->
@@ -104,16 +104,16 @@ $.after = (el, value) -> · 1 unmodified line
104104 value = buildFragment(value)
105105
106106 if el.nextSibling
107− el.parentElement.insertBefore(value, el.nextSibling)
107+ el.parentNode.insertBefore(value, el.nextSibling)
108108 else
109− el.parentElement.appendChild(value)
109+ el.parentNode.appendChild(value)
110110 return
111111
112112 $.remove = (value) ->
113113 if $.isCollection(value)
114− el.parentElement?.removeChild(el) for el in $.makeArray(value)
114+ el.parentNode?.removeChild(el) for el in $.makeArray(value)
115115 else
116− value.parentElement?.removeChild(value)
116+ value.parentNode?.removeChild(value)
117117 return
118118
119119 $.empty = (el) ->
@@ -155,7 +155,7 @@ $.offset = (el, container = document.body) -> · 35 unmodified lines
155155 left: left
156156
157157 $.scrollParent = (el) ->
158− while el = el.parentElement
158+ while el = el.parentNode
159159 break if el.scrollTop > 0
160160 break if getComputedStyle(el)?.overflowY in ['auto', 'scroll']
161161 el
assets/javascripts/views/list/list_focus.coffee+6−6
@@ -46,8 +46,8 @@ class app.views.ListFocus extends app.View · 45 unmodified lines
4646 @findNext(next)
4747 else if next.tagName is 'H6' # title
4848 @findNext(next)
49− else if cursor.parentElement isnt @el
50− @findNext cursor.parentElement
49+ else if cursor.parentNode isnt @el
50+ @findNext cursor.parentNode
5151
5252 findFirst: (cursor) ->
5353 return unless first = cursor.firstChild
@@ -72,8 +72,8 @@ class app.views.ListFocus extends app.View · 18 unmodified lines
7272 @findPrev(prev)
7373 else if prev.tagName is 'H6' # title
7474 @findPrev(prev)
75− else if cursor.parentElement isnt @el
76− @findPrev cursor.parentElement
75+ else if cursor.parentNode isnt @el
76+ @findPrev cursor.parentNode
7777
7878 findLast: (cursor) ->
7979 return unless last = cursor.lastChild
@@ -101,8 +101,8 @@ class app.views.ListFocus extends app.View · 21 unmodified lines
101101
102102 onLeft: =>
103103 cursor = @getCursor()
104− if cursor and not cursor.classList.contains(app.views.ListFold.activeClass) and cursor.parentElement isnt @el
105− @focusOnNextFrame cursor.parentElement.previousSibling
104+ if cursor and not cursor.classList.contains(app.views.ListFold.activeClass) and cursor.parentNode isnt @el
105+ @focusOnNextFrame cursor.parentNode.previousSibling
106106 return
107107
108108 onEnter: =>
assets/javascripts/views/list/list_fold.coffee+2−2
@@ -55,11 +55,11 @@ class app.views.ListFold extends app.View · 54 unmodified lines
5555 return if event.which isnt 1 or event.metaKey or event.ctrlKey
5656 return unless event.pageY # ignore fabricated clicks
5757 el = event.target
58− el = el.parentElement if el.parentElement.tagName.toUpperCase() is 'SVG'
58+ el = el.parentNode if el.parentNode.tagName.toUpperCase() is 'SVG'
5959
6060 if el.classList.contains @constructor.handleClass
6161 $.stopEvent(event)
62− @toggle el.parentElement
62+ @toggle el.parentNode
6363 else if el.classList.contains @constructor.targetClass
6464 if el.hasAttribute('href')
6565 if el.classList.contains(@constructor.activeClass)