From 0a669f05844086e403f6ac6f016f0c0e0ae0dd1e Mon Sep 17 00:00:00 2001 From: Jason Chen Date: Sat, 25 Oct 2014 19:22:03 -0700 Subject: [PATCH] fix tests for phantomjs --- src/core/editor.coffee | 2 +- src/core/selection.coffee | 4 +++- test/unit/core/selection.coffee | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/editor.coffee b/src/core/editor.coffee index 2c7e244a50..a0670c1bb2 100644 --- a/src/core/editor.coffee +++ b/src/core/editor.coffee @@ -71,7 +71,7 @@ class Editor focus: -> @selection.setRange(@selection.range) if dom.isIE(11) - @renderer.iframe.focus() if dom.isIOS() + @renderer.iframe.focus() @root.focus() getDelta: -> diff --git a/src/core/selection.coffee b/src/core/selection.coffee index 1bc98c9e6e..288daf12d8 100644 --- a/src/core/selection.coffee +++ b/src/core/selection.coffee @@ -144,7 +144,9 @@ class Selection return unless selection if startNode? # Some reason need to focus before removing ranges otherwise cannot set them - @doc.root.focus() unless this.checkFocus() + unless this.checkFocus() + @iframe.focus() + @doc.root.focus() nativeRange = this._getNativeRange() if !nativeRange? or startNode != nativeRange.startContainer or startOffset != nativeRange.startOffset or endNode != nativeRange.endContainer or endOffset != nativeRange.endOffset # IE9 requires removeAllRanges() regardless of value of diff --git a/test/unit/core/selection.coffee b/test/unit/core/selection.coffee index efd642839e..197d18582e 100644 --- a/test/unit/core/selection.coffee +++ b/test/unit/core/selection.coffee @@ -309,7 +309,7 @@ describe('Selection', -> expect(savedRange.end).toEqual(3) @quill.focus() range = @quill.getSelection() - expect(range).toBeTruthy() + expect(range).not.toEqual(null) expect(range.start).toEqual(2) expect(range.end).toEqual(3) done()