Skip to content

Commit 2f7a9a5

Browse files
committed
fix after review
1 parent 5434c61 commit 2f7a9a5

2 files changed

Lines changed: 10 additions & 16 deletions

File tree

packages/devextreme/js/__internal/ui/list/list.base.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,10 +1095,10 @@ export class ListBase extends CollectionWidget<ListBaseProperties, Item> {
10951095
on(eventName: string | { [key: string]: Function }, eventHandler?: Function): this {
10961096
const result = super.on(eventName, eventHandler);
10971097

1098-
const isItemSwipeOn = eventName === 'itemSwipe'
1098+
const hasItemSwipeHandler = eventName === 'itemSwipe'
10991099
|| (isPlainObject(eventName) && Object.prototype.hasOwnProperty.call(eventName, 'itemSwipe'));
11001100

1101-
if (isItemSwipeOn) {
1101+
if (hasItemSwipeHandler) {
11021102
this._updateSwipeEventSubscription();
11031103
}
11041104

packages/devextreme/testing/tests/DevExpress.ui.widgets/listParts/commonTests.js

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4809,7 +4809,7 @@ QUnit.module('Highlighting/selecting', { ...moduleSetup, afterEach: function() {
48094809

48104810
const getFirstListItemAndTextNode = ($list) => {
48114811
const $item = $list.find(`.${LIST_ITEM_CLASS}`).eq(0);
4812-
const textNode = $list.find(`.${LIST_ITEM_CONTENT_CLASS}`).eq(0).get(0).firstChild;
4812+
const textNode = $item.find(`.${LIST_ITEM_CONTENT_CLASS}`).eq(0).get(0).firstChild;
48134813

48144814
return { $item, textNode };
48154815
};
@@ -4820,16 +4820,15 @@ QUnit.module('Highlighting/selecting', { ...moduleSetup, afterEach: function() {
48204820
});
48214821

48224822
const { $item, textNode } = getFirstListItemAndTextNode(this.element);
4823-
assert.ok(!!textNode, 'text node found in list item');
4824-
if(!textNode) return;
4823+
4824+
assert.strictEqual(!!textNode, true, 'text node found in list item');
48254825

48264826
selectTextNodePart(textNode, 0, 4);
48274827
assert.strictEqual(window.getSelection().toString(), textNode.nodeValue.slice(0, 4), 'text selection exists before drag');
48284828

48294829
pointerMock($item).start().down(0, 0).move(50, 0).up();
48304830

4831-
assert.strictEqual(window.getSelection().toString(), textNode.nodeValue.slice(0, 4), 'text selection is preserved after horizontal drag');
4832-
window.getSelection().removeAllRanges();
4831+
assert.strictEqual(window.getSelection().toString(), textNode.nodeValue.slice(0, 4), 'text selection exists after drag');
48334832
});
48344833

48354834
QUnit.test('text selection should be preserved after onItemSwipe handler is removed from options', function(assert) {
@@ -4842,16 +4841,14 @@ QUnit.module('Highlighting/selecting', { ...moduleSetup, afterEach: function() {
48424841
list.option('onItemSwipe', null);
48434842

48444843
const { $item, textNode } = getFirstListItemAndTextNode(this.element);
4845-
assert.ok(!!textNode, 'text node found in list item');
4846-
if(!textNode) return;
4844+
assert.strictEqual(!!textNode, true, 'text node found in list item');
48474845

48484846
selectTextNodePart(textNode, 0, 4);
48494847
assert.strictEqual(window.getSelection().toString(), textNode.nodeValue.slice(0, 4), 'text selection exists before drag');
48504848

48514849
pointerMock($item).start().down(0, 0).move(50, 0).up();
48524850

4853-
assert.strictEqual(window.getSelection().toString(), textNode.nodeValue.slice(0, 4), 'text selection is preserved after drag when swipe handler is removed');
4854-
window.getSelection().removeAllRanges();
4851+
assert.strictEqual(window.getSelection().toString(), textNode.nodeValue.slice(0, 4), 'text selection exists after drag');
48554852
});
48564853

48574854
QUnit.test('text selection should reflect itemSwipe on/off subscription state', function(assert) {
@@ -4863,9 +4860,7 @@ QUnit.module('Highlighting/selecting', { ...moduleSetup, afterEach: function() {
48634860

48644861
const { $item, textNode } = getFirstListItemAndTextNode(this.element);
48654862

4866-
assert.ok(!!textNode, 'text node found in list item');
4867-
4868-
if(!textNode) return;
4863+
assert.strictEqual(!!textNode, true, 'text node found in list item');
48694864

48704865
list.on('itemSwipe', sinon.spy());
48714866

@@ -4883,8 +4878,7 @@ QUnit.module('Highlighting/selecting', { ...moduleSetup, afterEach: function() {
48834878

48844879
pointerMock($item).start().down(0, 0).move(50, 0).up();
48854880

4886-
assert.strictEqual(window.getSelection().toString(), textNode.nodeValue.slice(0, 4), 'text selection is preserved after drag when swipe handler is removed');
4887-
window.getSelection().removeAllRanges();
4881+
assert.strictEqual(window.getSelection().toString(), textNode.nodeValue.slice(0, 4), 'text selection exists after drag when swipe handler is removed');
48884882
});
48894883
});
48904884

0 commit comments

Comments
 (0)