Skip to content

Commit

Permalink
fix the "Get selection on input with "email" type" test in Firefox 68 (
Browse files Browse the repository at this point in the history
…close #2071) (#2077)
  • Loading branch information
Farfurix authored and LavrovArtem committed Jul 17, 2019
1 parent c28c5b4 commit 8816227
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
6 changes: 2 additions & 4 deletions Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ const CLIENT_TESTS_BROWSERS = [
},
{
platform: 'Windows 10',
browserName: 'firefox',
version: '67'
browserName: 'firefox'
},
{
platform: 'Windows 10',
Expand Down Expand Up @@ -86,8 +85,7 @@ const CLIENT_TESTS_BROWSERS = [
},
{
browserName: 'firefox',
platform: 'OS X 10.11',
version: '67'
platform: 'OS X 10.11'
}
];

Expand Down
6 changes: 3 additions & 3 deletions src/client/sandbox/event/selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ export default class Selection {
const selectionSetter = () => {
// NOTE: These browsers cannot restore the `selectionStart` and `selectionEnd` properties when we change the `type` attribute.
// So we need to use our own mechanism to store the `selectionStart` and `selectionEnd` properties.
const shouldChangeType = domUtils.isInputWithoutSelectionProperties(el);
const useInternalSelection = domUtils.isInputWithoutSelectionProperties(el);
const savedType = el.type;
let res;

if (shouldChangeType)
if (useInternalSelection)
el.type = 'text';

// NOTE: In MSEdge, an error occurs when the setSelectionRange method is called for an input with
Expand All @@ -60,7 +60,7 @@ export default class Selection {
res = fn.call(el, 0, 0, selectionDirection);
}

if (shouldChangeType) {
if (useInternalSelection ) {
el[INTERNAL_PROPS.selection] = {
selectionStart: el.selectionStart,
selectionEnd: el.selectionEnd,
Expand Down
2 changes: 1 addition & 1 deletion test/client/fixtures/sandbox/selection-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ test('Get selection on input with "email" type', function () {
var input = createTestInput('email', inputTestValue);
var selection = selectionSandbox.getSelection(input);

var isNotSupportedBrowser = browserUtils.isFirefox && browserVersion < 51 || isIE || browserUtils.isChrome && browserVersion > 74;
var isNotSupportedBrowser = browserUtils.isFirefox && browserVersion > 67 || isIE || browserUtils.isChrome && browserVersion > 74;

strictEqual(selection.start, isNotSupportedBrowser ? 0 : inputTestValue.length);
strictEqual(selection.end, isNotSupportedBrowser ? 0 : inputTestValue.length);
Expand Down

0 comments on commit 8816227

Please sign in to comment.