From 7b0e09b00aecda5569fa4ec97aad6847dfd9c34d Mon Sep 17 00:00:00 2001 From: gwarser Date: Sat, 7 Mar 2020 23:05:16 +0100 Subject: [PATCH] :upward() --- Procedural-cosmetic-filters.md | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Procedural-cosmetic-filters.md b/Procedural-cosmetic-filters.md index b41c258..4d9bf7b 100644 --- a/Procedural-cosmetic-filters.md +++ b/Procedural-cosmetic-filters.md @@ -124,8 +124,9 @@ Note that if _arg_ is valid CSS selector, uBO will not consider the `:not` opera ### `subject:nth-ancestor(n)` -- Description: lookup the nth ancestor relative to the currently selected -node. +Deprecated in favor of [`subject:upward(arg)`](#subjectupwardarg) in [1.25.3b0](https://github.com/gorhill/uBlock/commit/72bb70056843024b1a31fe1ab9c90bd4e8260ba2) + +- Description: lookup the nth ancestor relative to the currently selected node. - Chainable: Yes. - _subject_: Can be a plain CSS selector, or a procedural cosmetic filter. - _n_: positive number >= 1 and < 256, distance from the currently selected node. @@ -136,6 +137,23 @@ Introduced in uBO [1.18.17rc1](https://github.com/gorhill/uBlock/commit/73e2f25e *** +### `subject:upward(arg)` + +- Description: lookup the ancestor relative to the currently selected node. +- Chainable: Yes. +- _subject_: Can be a plain CSS selector, or a procedural cosmetic filter. +- _arg_: + - Positive number >= 1 and < 256, distance from the currently selected node. + - A valid plain CSS selector. +- Examples: + - Existing filter: `fastbay.org##.detLink:has-text(VPN):xpath(../../..)` can be rewritten as `fastbay.org##.detLink:has-text(VPN):upward(3)` + +Introduced in uBO [1.25.3b0](https://github.com/gorhill/uBlock/commit/72bb70056843024b1a31fe1ab9c90bd4e8260ba2). Evolution of [`:nth-ancestor(n)`](#subjectnth-ancestorn) selector. + +See also [`Element.closest()` ↪](https://developer.mozilla.org/en-US/docs/Web/API/Element/closest) + +*** + ### `subject:watch-attrs(arg)` Deprecated in favor of [`subject:watch-attr(arg)`](#subjectwatch-attrarg) in [1.20.1b3](https://github.com/gorhill/uBlock/commit/41685f4cce084f3f89e9cdd8fc1cde5b57862958)