Merge branch 'lgeiger-patch-1'

This commit is contained in:
Antonio Scandurra
2016-11-24 10:14:28 +01:00
2 changed files with 35 additions and 1 deletions

View File

@@ -3846,6 +3846,40 @@ describe('TextEditorComponent', function () {
})
})
describe('when the mousewheel event\'s target is an SVG element inside a block decoration', function () {
it('keeps the block decoration on the DOM if it is scrolled off-screen', function () {
wrapperNode.style.height = 4.5 * lineHeightInPixels + 'px'
wrapperNode.style.width = 20 * charWidth + 'px'
editor.update({autoHeight: false})
component.measureDimensions()
runAnimationFrames()
const item = document.createElement('div')
const svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg")
item.appendChild(svgElement)
editor.decorateMarker(
editor.markScreenPosition([0, 0], {invalidate: "never"}),
{type: "block", item: item}
)
runAnimationFrames()
let wheelEvent = new WheelEvent('mousewheel', {
wheelDeltaX: 0,
wheelDeltaY: -500
})
Object.defineProperty(wheelEvent, 'target', {
get: function () {
return svgElement
}
})
componentNode.dispatchEvent(wheelEvent)
runAnimationFrames()
expect(component.getTopmostDOMNode().contains(item)).toBe(true)
})
})
it('only prevents the default action of the mousewheel event if it actually lead to scrolling', function () {
spyOn(WheelEvent.prototype, 'preventDefault').andCallThrough()
wrapperNode.style.height = 4.5 * lineHeightInPixels + 'px'

View File

@@ -909,7 +909,7 @@ class TextEditorComponent
screenRowForNode: (node) ->
while node?
if screenRow = node.dataset.screenRow
if screenRow = node.dataset?.screenRow
return parseInt(screenRow)
node = node.parentElement
null