-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update dom-selector and roll web platform tests
This update simplifies the integration with jsdom's exceptions, and fixes some of the WPTs introduced in this roll.
- Loading branch information
Showing
9 changed files
with
730 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,92 +1,33 @@ | ||
"use strict"; | ||
|
||
const domSelector = require("@asamuzakjp/dom-selector"); | ||
const DOMException = require("../generated/DOMException"); | ||
const idlUtils = require("../generated/utils"); | ||
const { wrapperForImpl } = require("../generated/utils"); | ||
|
||
exports.matchesDontThrow = (selectors, elementImpl) => { | ||
let matched; | ||
const element = wrapperForImpl(elementImpl); | ||
try { | ||
const element = idlUtils.wrapperForImpl(elementImpl); | ||
matched = domSelector.matches(selectors, element); | ||
return domSelector.matches(selectors, element); | ||
} catch { | ||
matched = false; | ||
return false; | ||
} | ||
return matched; | ||
}; | ||
|
||
exports.matches = (selectors, elementImpl, globalObject) => { | ||
let matched; | ||
try { | ||
const element = idlUtils.wrapperForImpl(elementImpl); | ||
matched = domSelector.matches(selectors, element); | ||
} catch (e) { | ||
if (e instanceof globalThis.DOMException && | ||
!(e instanceof globalObject.DOMException)) { | ||
throw DOMException.create(globalObject, [e.message, e.name]); | ||
} else if (e instanceof globalThis.TypeError && | ||
!(e instanceof globalObject.TypeError)) { | ||
throw new globalObject.TypeError(e.message); | ||
} else { | ||
throw e; | ||
} | ||
} | ||
return matched; | ||
exports.matches = (selectors, elementImpl) => { | ||
const element = wrapperForImpl(elementImpl); | ||
return domSelector.matches(selectors, element); | ||
}; | ||
|
||
exports.closest = (selectors, elementImpl, globalObject) => { | ||
let matched; | ||
try { | ||
const element = idlUtils.wrapperForImpl(elementImpl); | ||
matched = domSelector.closest(selectors, element); | ||
} catch (e) { | ||
if (e instanceof globalThis.DOMException && | ||
!(e instanceof globalObject.DOMException)) { | ||
throw DOMException.create(globalObject, [e.message, e.name]); | ||
} else if (e instanceof globalThis.TypeError && | ||
!(e instanceof globalObject.TypeError)) { | ||
throw new globalObject.TypeError(e.message); | ||
} else { | ||
throw e; | ||
} | ||
} | ||
return matched; | ||
exports.closest = (selectors, elementImpl) => { | ||
const element = wrapperForImpl(elementImpl); | ||
return domSelector.closest(selectors, element); | ||
}; | ||
|
||
exports.querySelector = (selectors, parentNodeImpl, globalObject) => { | ||
let matched; | ||
try { | ||
const node = idlUtils.wrapperForImpl(parentNodeImpl); | ||
matched = domSelector.querySelector(selectors, node); | ||
} catch (e) { | ||
if (e instanceof globalThis.DOMException && | ||
!(e instanceof globalObject.DOMException)) { | ||
throw DOMException.create(globalObject, [e.message, e.name]); | ||
} else if (e instanceof globalThis.TypeError && | ||
!(e instanceof globalObject.TypeError)) { | ||
throw new globalObject.TypeError(e.message); | ||
} else { | ||
throw e; | ||
} | ||
} | ||
return matched; | ||
exports.querySelector = (selectors, parentNodeImpl) => { | ||
const node = wrapperForImpl(parentNodeImpl); | ||
return domSelector.querySelector(selectors, node); | ||
}; | ||
|
||
exports.querySelectorAll = (selectors, parentNodeImpl, globalObject) => { | ||
let matched; | ||
try { | ||
const node = idlUtils.wrapperForImpl(parentNodeImpl); | ||
matched = domSelector.querySelectorAll(selectors, node); | ||
} catch (e) { | ||
if (e instanceof globalThis.DOMException && | ||
!(e instanceof globalObject.DOMException)) { | ||
throw DOMException.create(globalObject, [e.message, e.name]); | ||
} else if (e instanceof globalThis.TypeError && | ||
!(e instanceof globalObject.TypeError)) { | ||
throw new globalObject.TypeError(e.message); | ||
} else { | ||
throw e; | ||
} | ||
} | ||
return matched; | ||
exports.querySelectorAll = (selectors, parentNodeImpl) => { | ||
const node = wrapperForImpl(parentNodeImpl); | ||
return domSelector.querySelectorAll(selectors, node); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.