Comparing version 1.6.0 to 1.7.0
@@ -27,2 +27,4 @@ import inViewport from './src/dimension/in-viewport'; | ||
import matches from './src/query/matches'; | ||
import select from './src/query/select'; | ||
import selectAll from './src/query/select-all'; | ||
import tabbable from './src/query/tabbable'; | ||
@@ -63,3 +65,5 @@ | ||
matches, | ||
select, | ||
selectAll, | ||
tabbable | ||
}; |
{ | ||
"name": "domestique", | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"description": "A modular DOM helper library.", | ||
@@ -44,3 +44,7 @@ "repository": "https://github.com/jsor/domestique.git", | ||
} | ||
] | ||
], | ||
"unicorn/prefer-dataset": "off", | ||
"unicorn/prefer-includes": "off", | ||
"unicorn/prefer-node-append": "off", | ||
"unicorn/prefer-node-remove": "off" | ||
}, | ||
@@ -65,3 +69,3 @@ "ignores": [ | ||
"lint": "xo", | ||
"test": "npm run lint && npm run compat && karma start --single-run", | ||
"test": "npm run lint && karma start --single-run", | ||
"test:browserstack": "npm run build:test:browserstack && browserstack-runner", | ||
@@ -75,19 +79,19 @@ "test:browserstack-legacy": "npm run build:test:browserstack-legacy && BROWSERSTACK_JSON=browserstack-legacy.json browserstack-runner" | ||
"browserstack-runner": "^0.9.0", | ||
"chai": "^4.1.2", | ||
"compat-cli": "^0.1.3", | ||
"chai": "^4.2.0", | ||
"compat-cli": "^0.1.4", | ||
"istanbul-instrumenter-loader": "^3.0.1", | ||
"karma": "^3.0.0", | ||
"karma": "^4.3.0", | ||
"karma-chai": "^0.1.0", | ||
"karma-chrome-launcher": "^2.2.0", | ||
"karma-coverage": "^1.1.2", | ||
"karma-coverage-istanbul-reporter": "^2.0.2", | ||
"karma-firefox-launcher": "^1.1.0", | ||
"karma-chrome-launcher": "^3.1.0", | ||
"karma-coverage": "^2.0.1", | ||
"karma-coverage-istanbul-reporter": "^2.1.0", | ||
"karma-firefox-launcher": "^1.2.0", | ||
"karma-mocha": "^1.3.0", | ||
"karma-mocha-reporter": "^2.2.5", | ||
"karma-webpack": "^3.0.0", | ||
"mocha": "^5.2.0", | ||
"webpack": "^4.17.1", | ||
"webpack-cli": "^3.1.0", | ||
"xo": "^0.22.0" | ||
"karma-webpack": "^4.0.2", | ||
"mocha": "^6.2.1", | ||
"webpack": "^4.41.0", | ||
"webpack-cli": "^3.3.9", | ||
"xo": "^0.25.3" | ||
} | ||
} |
@@ -57,2 +57,4 @@ Domestique | ||
matches, | ||
select, | ||
selectAll, | ||
tabbable | ||
@@ -94,2 +96,4 @@ } from 'domestique'; | ||
* [matches()](#matches) | ||
* [select()](#select) | ||
* [selectAll()](#selectall) | ||
* [tabbable()](#tabbable) | ||
@@ -570,2 +574,4 @@ | ||
*Deprecated in favor of [selectAll()](#selectall). To be removed in 2.0.* | ||
``` | ||
@@ -584,3 +590,3 @@ find(selector: string[, element: Element]): array | ||
const spansInsideFirstParagraph = find('spans', paragraphs[0]); | ||
const spansInsideFirstParagraph = find('span', paragraphs[0]); | ||
``` | ||
@@ -595,3 +601,3 @@ | ||
Returns an `array` of focusable elements in the DOM which are | ||
descendants of the `document` or the `element` specified as optional second | ||
descendants of the `document` or the `element` specified as optional first | ||
argument. | ||
@@ -629,2 +635,36 @@ | ||
#### select() | ||
``` | ||
select(context: Element, selector: string): Element | ||
``` | ||
Returns the descendant of `context` (`document` or `Element`) which matches the | ||
specified `selector`. If no element could be found, `null` is returned. | ||
##### Example | ||
```javascript | ||
const paragraph = select(document, 'p'); | ||
const spanInsideParagraph = select(paragraph, 'span'); | ||
``` | ||
#### selectAll() | ||
``` | ||
select(context: Element, selector: string): array | ||
``` | ||
Returns an `array` of all descendants of `context` (`document` or `Element`) | ||
which match the specified `selector`. | ||
##### Example | ||
```javascript | ||
const allParagraphs = selectAll(document, 'p'); | ||
const allSpansInsideFirstParagraph = selectAll(paragraph[0], 'span'); | ||
``` | ||
#### tabbable() | ||
@@ -637,3 +677,3 @@ | ||
Returns an `array` of keyboard focusable ("tabbable") elements in the DOM which | ||
are descendants of the `document` or the `element` specified as optional second | ||
are descendants of the `document` or the `element` specified as optional first | ||
argument. | ||
@@ -640,0 +680,0 @@ |
@@ -11,5 +11,5 @@ /* | ||
return activeElement && activeElement.nodeName ? activeElement : document.body; | ||
} catch (e) { | ||
} catch (_) { | ||
return document.body; | ||
} | ||
} |
@@ -40,3 +40,3 @@ /* | ||
return JSON.parse(data); | ||
} catch (e) { | ||
} catch (_) { | ||
return data; | ||
@@ -43,0 +43,0 @@ } |
@@ -12,3 +12,3 @@ import scrollPositionRestorer from '../util/scroll-position-restorer'; | ||
element.focus(); | ||
} catch (e) { | ||
} catch (_) { | ||
// Ignore errors, eg. from SVG elements in Firefox, IE and Edge | ||
@@ -15,0 +15,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import find from '../query/find'; | ||
import selectAll from '../query/select-all'; | ||
import fragmentContainer from '../util/fragment-container'; | ||
@@ -7,3 +7,3 @@ | ||
const result = find('[ref]', container).reduce( | ||
const result = selectAll(container, '[ref]').reduce( | ||
(result, element) => { | ||
@@ -10,0 +10,0 @@ const [, refName, isArray] = element |
@@ -15,3 +15,3 @@ export default function dispatch(target, type, eventInit = {}) { | ||
event = new CustomEvent(type, eventInit); | ||
} catch (err) { | ||
} catch (_) { | ||
event = document.createEvent('CustomEvent'); | ||
@@ -18,0 +18,0 @@ event.initCustomEvent( |
@@ -0,1 +1,4 @@ | ||
/** | ||
* @deprecated Deprecated in favor of selectAll(). To be removed in 2.0. | ||
*/ | ||
export default function find(selector, element) { | ||
@@ -2,0 +5,0 @@ // Check here for explicitly passed element argument. |
import {compare, focusableFilter, selector} from '../util/focus'; | ||
import find from './find'; | ||
import selectAll from './select-all'; | ||
export default function focusable(element) { | ||
return find(selector, arguments.length > 0 ? element : document) | ||
return selectAll(arguments.length > 0 ? element : document, selector) | ||
.filter(focusableFilter) | ||
.sort(compare); | ||
} |
import {compare, selector, tabbableFilter} from '../util/focus'; | ||
import find from './find'; | ||
import selectAll from './select-all'; | ||
export default function tabbable(element) { | ||
return find(selector, arguments.length > 0 ? element : document) | ||
return selectAll(arguments.length > 0 ? element : document, selector) | ||
.filter(tabbableFilter) | ||
.sort(compare); | ||
} |
import closest from '../query/closest'; | ||
import find from '../query/find'; | ||
import parents from '../element/parents'; | ||
import selectAll from '../query/select-all'; | ||
@@ -82,3 +82,3 @@ /* | ||
const images = find(`img[usemap="#${mapName}"]`); | ||
const images = selectAll(document, `img[usemap="#${mapName}"]`); | ||
@@ -85,0 +85,0 @@ return images.length > 0 && visible(images[0]); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39913
35
656
739