You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@annotator.apache.org by ge...@apache.org on 2021/06/04 19:05:17 UTC

[incubator-annotator] 01/03: Make css matcher return an Element, not Range

This is an automated email from the ASF dual-hosted git repository.

gerben pushed a commit to branch allow-node-as-scope
in repository https://gitbox.apache.org/repos/asf/incubator-annotator.git

commit acf3d140c4468da0666257997c2ce56083628bcc
Author: Gerben <ge...@treora.com>
AuthorDate: Fri Jun 4 19:23:23 2021 +0200

    Make css matcher return an Element, not Range
---
 packages/dom/src/css.ts | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/packages/dom/src/css.ts b/packages/dom/src/css.ts
index 1026004..6882b1e 100644
--- a/packages/dom/src/css.ts
+++ b/packages/dom/src/css.ts
@@ -45,11 +45,6 @@ import { ownerDocument } from './owner-document';
  * > “If […] the user agent discovers multiple matching text sequences, then the
  * > selection SHOULD be treated as matching all of the matches.”
  *
- * Each matching element is returned as a {@link https://developer.mozilla.org/en-US/docs/Web/API/Range
- * | Range} surrounding that element. This in order to make its output reusable
- * as the scope for any subsequents selectors that {@link
- * Selector.refinedBy | refine} this CssSelector.
- *
  * @param selector - The {@link CssSelector} to be anchored
  * @returns A {@link Matcher} function that applies `selector` to a given {@link https://developer.mozilla.org/en-US/docs/Web/API/Range
  * | Range}
@@ -58,7 +53,7 @@ import { ownerDocument } from './owner-document';
  */
 export function createCssSelectorMatcher(
   selector: CssSelector,
-): Matcher<Range, Range> {
+): Matcher<Range, Element> {
   return async function* matchAll(scope) {
     const document = ownerDocument(scope);
     for (const element of document.querySelectorAll(selector.value)) {
@@ -69,7 +64,7 @@ export function createCssSelectorMatcher(
         scope.isPointInRange(range.startContainer, range.startOffset) &&
         scope.isPointInRange(range.endContainer, range.endOffset)
       ) {
-        yield range;
+        yield element;
       }
     }
   };