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

pull/669/head
Thibaut Courouble 8 years ago
parent eea7596dad
commit 53f666a742

@ -171,7 +171,7 @@ onclick = (event) ->
return return
link = event.target link = event.target
link = link.parentElement while link and link.tagName isnt 'A' link = link.parentNode while link and link.tagName isnt 'A'
if link and not link.target and isSameOrigin(link.href) if link and not link.target and isSameOrigin(link.href)
event.preventDefault() event.preventDefault()

@ -16,13 +16,13 @@ $.hasChild = (parent, el) ->
while el while el
return true if el is parent return true if el is parent
return if el is document.body return if el is document.body
el = el.parentElement el = el.parentNode
$.closestLink = (el, parent = document.body) -> $.closestLink = (el, parent = document.body) ->
while el while el
return el if el.tagName is 'A' return el if el.tagName is 'A'
return if el is parent return if el is parent
el = el.parentElement el = el.parentNode
# #
# Events # Events
@ -96,7 +96,7 @@ $.before = (el, value) ->
if typeof value is 'string' or $.isCollection(value) if typeof value is 'string' or $.isCollection(value)
value = buildFragment(value) value = buildFragment(value)
el.parentElement.insertBefore(value, el) el.parentNode.insertBefore(value, el)
return return
$.after = (el, value) -> $.after = (el, value) ->
@ -104,16 +104,16 @@ $.after = (el, value) ->
value = buildFragment(value) value = buildFragment(value)
if el.nextSibling if el.nextSibling
el.parentElement.insertBefore(value, el.nextSibling) el.parentNode.insertBefore(value, el.nextSibling)
else else
el.parentElement.appendChild(value) el.parentNode.appendChild(value)
return return
$.remove = (value) -> $.remove = (value) ->
if $.isCollection(value) if $.isCollection(value)
el.parentElement?.removeChild(el) for el in $.makeArray(value) el.parentNode?.removeChild(el) for el in $.makeArray(value)
else else
value.parentElement?.removeChild(value) value.parentNode?.removeChild(value)
return return
$.empty = (el) -> $.empty = (el) ->
@ -155,7 +155,7 @@ $.offset = (el, container = document.body) ->
left: left left: left
$.scrollParent = (el) -> $.scrollParent = (el) ->
while el = el.parentElement while el = el.parentNode
break if el.scrollTop > 0 break if el.scrollTop > 0
break if getComputedStyle(el)?.overflowY in ['auto', 'scroll'] break if getComputedStyle(el)?.overflowY in ['auto', 'scroll']
el el

@ -46,8 +46,8 @@ class app.views.ListFocus extends app.View
@findNext(next) @findNext(next)
else if next.tagName is 'H6' # title else if next.tagName is 'H6' # title
@findNext(next) @findNext(next)
else if cursor.parentElement isnt @el else if cursor.parentNode isnt @el
@findNext cursor.parentElement @findNext cursor.parentNode
findFirst: (cursor) -> findFirst: (cursor) ->
return unless first = cursor.firstChild return unless first = cursor.firstChild
@ -72,8 +72,8 @@ class app.views.ListFocus extends app.View
@findPrev(prev) @findPrev(prev)
else if prev.tagName is 'H6' # title else if prev.tagName is 'H6' # title
@findPrev(prev) @findPrev(prev)
else if cursor.parentElement isnt @el else if cursor.parentNode isnt @el
@findPrev cursor.parentElement @findPrev cursor.parentNode
findLast: (cursor) -> findLast: (cursor) ->
return unless last = cursor.lastChild return unless last = cursor.lastChild
@ -101,8 +101,8 @@ class app.views.ListFocus extends app.View
onLeft: => onLeft: =>
cursor = @getCursor() cursor = @getCursor()
if cursor and not cursor.classList.contains(app.views.ListFold.activeClass) and cursor.parentElement isnt @el if cursor and not cursor.classList.contains(app.views.ListFold.activeClass) and cursor.parentNode isnt @el
@focusOnNextFrame cursor.parentElement.previousSibling @focusOnNextFrame cursor.parentNode.previousSibling
return return
onEnter: => onEnter: =>

@ -55,11 +55,11 @@ class app.views.ListFold extends app.View
return if event.which isnt 1 or event.metaKey or event.ctrlKey return if event.which isnt 1 or event.metaKey or event.ctrlKey
return unless event.pageY # ignore fabricated clicks return unless event.pageY # ignore fabricated clicks
el = event.target el = event.target
el = el.parentElement if el.parentElement.tagName.toUpperCase() is 'SVG' el = el.parentNode if el.parentNode.tagName.toUpperCase() is 'SVG'
if el.classList.contains @constructor.handleClass if el.classList.contains @constructor.handleClass
$.stopEvent(event) $.stopEvent(event)
@toggle el.parentElement @toggle el.parentNode
else if el.classList.contains @constructor.targetClass else if el.classList.contains @constructor.targetClass
if el.hasAttribute('href') if el.hasAttribute('href')
if el.classList.contains(@constructor.activeClass) if el.classList.contains(@constructor.activeClass)

Loading…
Cancel
Save