@@ -4791,6 +4791,70 @@ QUnit.module('Search', () => {
47914791 } ) ;
47924792} ) ;
47934793
4794+ QUnit . module ( 'Highlighting' , ( ) => {
4795+
4796+ const selectTextNodePart = ( textNode , startOffset , endOffset ) => {
4797+ const selection = window . getSelection ( ) ;
4798+ const range = document . createRange ( ) ;
4799+
4800+ selection . removeAllRanges ( ) ;
4801+ range . setStart ( textNode , startOffset ) ;
4802+ range . setEnd ( textNode , endOffset ) ;
4803+ selection . addRange ( range ) ;
4804+
4805+ return selection ;
4806+ } ;
4807+
4808+ QUnit . test ( 'list item should not block native text selection events' , function ( assert ) {
4809+ const $list = $ ( '#list' ) . dxList ( {
4810+ items : [ 'Item 1' , 'Item 2' ]
4811+ } ) ;
4812+
4813+ const item = $list . find ( `.${ LIST_ITEM_CLASS } ` ) . eq ( 0 ) . get ( 0 ) ;
4814+
4815+ const mouseDownEvent = new MouseEvent ( 'mousedown' , {
4816+ bubbles : true ,
4817+ cancelable : true ,
4818+ clientX : 10 ,
4819+ clientY : 10 ,
4820+ } ) ;
4821+
4822+ const selectStartEvent = new Event ( 'selectstart' , {
4823+ bubbles : true ,
4824+ cancelable : true ,
4825+ } ) ;
4826+
4827+ const mouseDownNotCanceled = item . dispatchEvent ( mouseDownEvent ) ;
4828+ const selectStartNotCanceled = item . dispatchEvent ( selectStartEvent ) ;
4829+
4830+ assert . ok ( mouseDownNotCanceled , 'mousedown is not canceled' ) ;
4831+ assert . notOk ( mouseDownEvent . defaultPrevented , 'mousedown default is not prevented' ) ;
4832+ assert . ok ( selectStartNotCanceled , 'selectstart is not canceled' ) ;
4833+ assert . notOk ( selectStartEvent . defaultPrevented , 'selectstart default is not prevented' ) ;
4834+ } ) ;
4835+
4836+ QUnit . test ( 'text node should be selectable via Selection API' , function ( assert ) {
4837+ const $list = $ ( '#list' ) . dxList ( {
4838+ items : [ 'Item 1' , 'Item 2' ]
4839+ } ) ;
4840+
4841+ const $item = $list . find ( '.dx-list-item-content' ) . eq ( 0 ) ;
4842+ const textNode = $item . get ( 0 ) . firstChild ;
4843+
4844+ assert . ok ( ! ! textNode , 'text node exists' ) ;
4845+
4846+ if ( ! textNode ) {
4847+ return ;
4848+ }
4849+
4850+ const expected = textNode . textContent . slice ( 0 , 4 ) ;
4851+ const selection = selectTextNodePart ( textNode , 0 , 4 ) ;
4852+
4853+ assert . strictEqual ( selection . toString ( ) , expected , 'text is selected' ) ;
4854+ selection . removeAllRanges ( ) ;
4855+ } ) ;
4856+ } ) ;
4857+
47944858let helper ;
47954859if ( devices . real ( ) . deviceType === 'desktop' ) {
47964860 [ true , false ] . forEach ( ( searchEnabled ) => {
0 commit comments