* Adds elements to the selection * * @param query - CSS Query, can be an array of queries * @param quiet - If this should not trigger the move event
(query: SelectAllSelectors, quiet = false)
| 893 | * @param quiet - If this should not trigger the move event |
| 894 | */ |
| 895 | select(query: SelectAllSelectors, quiet = false): Element[] { |
| 896 | const { changed, selected, stored } = this._selection; |
| 897 | const elements = selectAll(query, this._options.document).filter( |
| 898 | (el) => !selected.includes(el) && !stored.includes(el) |
| 899 | ); |
| 900 | |
| 901 | // Update element lists |
| 902 | stored.push(...elements); |
| 903 | selected.push(...elements); |
| 904 | changed.added.push(...elements); |
| 905 | changed.removed = []; |
| 906 | |
| 907 | // We don't know which element was "selected" first so clear it |
| 908 | this._latestElement = undefined; |
| 909 | |
| 910 | // Fire event |
| 911 | if (!quiet) { |
| 912 | this._emitEvent('move', null); |
| 913 | this._emitEvent('stop', null); |
| 914 | } |
| 915 | |
| 916 | return elements; |
| 917 | } |
| 918 | |
| 919 | /** |
| 920 | * Manually triggers the start of a selection |
no test coverage detected