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 18:37:44 UTC

[incubator-annotator] branch master updated: Make default scope of describeCss the whole document

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

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


The following commit(s) were added to refs/heads/master by this push:
     new cf5a13c  Make default scope of describeCss the whole document
cf5a13c is described below

commit cf5a13c2edd9c9207d2b205ac83f9564ad112eb4
Author: Gerben <ge...@treora.com>
AuthorDate: Fri Jun 4 19:02:47 2021 +0200

    Make default scope of describeCss the whole document
    
    Instead of just the body.
    
    Accordingly, allow any Node as scope, not only Elements.
---
 packages/dom/src/css.ts | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/packages/dom/src/css.ts b/packages/dom/src/css.ts
index 1a62141..746486a 100644
--- a/packages/dom/src/css.ts
+++ b/packages/dom/src/css.ts
@@ -77,9 +77,9 @@ export function createCssSelectorMatcher(
 
 export async function describeCss(
   element: HTMLElement,
-  scope?: HTMLElement,
+  scope: Node = element.ownerDocument,
 ): Promise<CssSelector> {
-  const selector = optimalSelect(element, { root: scope ?? element.ownerDocument.body });
+  const selector = optimalSelect(element, { root: scope });
   return {
     type: 'CssSelector',
     value: selector,