@@ -218,3 +218,189 @@ export const SUPPORTED_PREPROCESSOR_DIRECTIVES = new Set([
218218
219219export const REMOVE_PROPERTY = 'remove' ;
220220export const REMOVE_VALUE = 'true' ;
221+
222+ /**
223+ * Supported Extended CSS pseudo-classes.
224+ *
225+ * These pseudo-classes are not supported by browsers natively, so we need Extended CSS library to support them.
226+ *
227+ * Please keep this list sorted alphabetically.
228+ */
229+ export const SUPPORTED_EXT_CSS_PSEUDO_CLASSES = new Set ( [
230+ /**
231+ * Pseudo-classes :is(), and :not() may use native implementation.
232+ *
233+ * @see {@link https://github.com/AdguardTeam/ExtendedCss#extended-css-is }
234+ * @see {@link https://github.com/AdguardTeam/ExtendedCss#extended-css-not }
235+ */
236+ /**
237+ * :has() should also be conditionally considered as extended and should not be in this list,
238+ * for details check: https://github.com/AdguardTeam/ExtendedCss#extended-css-has,
239+ * but there is a bug with content blocker in safari:
240+ * for details check: https://bugs.webkit.org/show_bug.cgi?id=248868.
241+ *
242+ * TODO: remove 'has' later.
243+ */
244+ '-abp-contains' , // alias for 'contains'
245+ '-abp-has' , // alias for 'has'
246+ 'contains' ,
247+ 'has' , // some browsers support 'has' natively
248+ 'has-text' , // alias for 'contains'
249+ 'if' ,
250+ 'if-not' ,
251+ 'matches-attr' ,
252+ 'matches-css' ,
253+ 'matches-css-after' , // deprecated, replaced by 'matches-css'
254+ 'matches-css-before' , // deprecated, replaced by 'matches-css'
255+ 'matches-property' ,
256+ 'nth-ancestor' ,
257+ 'remove' ,
258+ 'upward' ,
259+ 'xpath' ,
260+ 'style' ,
261+ 'matches-media' ,
262+ ] ) ;
263+
264+ // TODO: Use compatibility tables once they support Extended CSS pseudo-classes.
265+ // https://github.com/AdguardTeam/tsurlfilter/issues/175
266+
267+ /**
268+ * Supported Extended CSS pseudo-classes.
269+ *
270+ * These pseudo-classes are not supported by browsers natively, so we need Extended CSS library to support them.
271+ *
272+ * Please keep this list sorted alphabetically.
273+ */
274+ export const SUPPORTED_ADG_PSEUDO_CLASSES : ReadonlySet < string > = new Set ( [
275+ /**
276+ * Pseudo-classes :is(), and :not() may use native implementation.
277+ *
278+ * @see {@link https://github.com/AdguardTeam/ExtendedCss#extended-css-is }
279+ * @see {@link https://github.com/AdguardTeam/ExtendedCss#extended-css-not }
280+ */
281+ /**
282+ * :has() should also be conditionally considered as extended and should not be in this list,
283+ * for details check: https://github.com/AdguardTeam/ExtendedCss#extended-css-has,
284+ * but there is a bug with content blocker in safari:
285+ * for details check: https://bugs.webkit.org/show_bug.cgi?id=248868.
286+ *
287+ * TODO: remove 'has' later.
288+ */
289+ '-abp-contains' , // alias for 'contains'
290+ '-abp-has' , // alias for 'has'
291+ 'contains' ,
292+ 'has' , // some browsers support 'has' natively
293+ 'has-text' , // alias for 'contains'
294+ 'if' ,
295+ 'if-not' ,
296+ 'matches-attr' ,
297+ 'matches-css' ,
298+ 'matches-css-after' , // deprecated, replaced by 'matches-css'
299+ 'matches-css-before' , // deprecated, replaced by 'matches-css'
300+ 'matches-property' ,
301+ 'nth-ancestor' ,
302+ 'remove' ,
303+ 'upward' ,
304+ 'xpath' ,
305+ ] ) ;
306+
307+ /**
308+ * Supported ABP Extended CSS pseudo-classes.
309+ *
310+ * These pseudo-classes are not supported by browsers natively, so we need Extended CSS library to support them.
311+ *
312+ * Please keep this list sorted alphabetically.
313+ *
314+ * @see {@link https://help.adblockplus.org/hc/en-us/articles/360062733293-How-to-write-filters#elemhide-emulation }
315+ */
316+ export const SUPPORTED_ABP_PSEUDO_CLASSES : ReadonlySet < string > = new Set ( [
317+ '-abp-contains' ,
318+ '-abp-has' ,
319+ '-abp-properties' ,
320+ 'xpath' ,
321+ ] ) ;
322+
323+ /**
324+ * Supported uBlock action operators.
325+ *
326+ * @see {@link https://github.com/gorhill/uBlock/wiki/Static-filter-syntax#action-operators }
327+ */
328+ export const SUPPORTED_UBO_ACTION_OPERATORS = new Set ( [
329+ 'remove' ,
330+ 'remove-attr' ,
331+ 'remove-class' ,
332+ 'style' ,
333+ ] ) ;
334+
335+ /**
336+ * Supported uBlock procedural pseudo-classes.
337+ *
338+ * @see {@link https://github.com/gorhill/uBlock/wiki/Static-filter-syntax#procedural-cosmetic-filters }
339+ * @see {@link https://github.com/gorhill/uBlock/wiki/Static-filter-syntax#action-operators }
340+ */
341+ export const SUPPORTED_UBO_PSEUDO_CLASSES : ReadonlySet < string > = new Set ( [
342+ 'has' ,
343+ 'has-text' ,
344+ 'matches-attr' ,
345+ 'matches-css' ,
346+ 'matches-css-after' ,
347+ 'matches-css-before' ,
348+ 'matches-media' ,
349+ 'matches-path' ,
350+ 'matches-prop' ,
351+ 'min-text-length' ,
352+ 'not' ,
353+ 'others' ,
354+ 'upward' ,
355+ 'watch-attr' ,
356+ 'xpath' ,
357+ ...SUPPORTED_UBO_ACTION_OPERATORS ,
358+ ] ) ;
359+
360+ /**
361+ * Supported native CSS pseudo-classes.
362+ *
363+ * These pseudo-classes are supported by browsers natively, so we don't need Extended CSS library to support them.
364+ *
365+ * The problem with pseudo-classes is that any unknown pseudo-class makes browser ignore the whole CSS rule,
366+ * which contains a lot more selectors. So, if CSS selector contains a pseudo-class, we should try to validate it.
367+ * One more problem with pseudo-classes is that they are actively used in uBlock, hence it may mess AG styles.
368+ *
369+ * Please keep this list sorted alphabetically.
370+ */
371+ export const SUPPORTED_CSS_PSEUDO_CLASSES = new Set ( [
372+ 'active' , // https://developer.mozilla.org/en-US/docs/Web/CSS/:active
373+ 'checked' , // https://developer.mozilla.org/en-US/docs/Web/CSS/:checked
374+ 'disabled' , // https://developer.mozilla.org/en-US/docs/Web/CSS/:disabled
375+ 'empty' , // https://developer.mozilla.org/en-US/docs/Web/CSS/:empty
376+ 'enabled' , // https://developer.mozilla.org/en-US/docs/Web/CSS/:enabled
377+ 'first-child' , // https://developer.mozilla.org/en-US/docs/Web/CSS/:first-child
378+ 'first-of-type' , // https://developer.mozilla.org/en-US/docs/Web/CSS/:first-of-type
379+ 'focus' , // https://developer.mozilla.org/en-US/docs/Web/CSS/:focus
380+ 'has' , // https://developer.mozilla.org/en-US/docs/Web/CSS/:has
381+ 'hover' , // https://developer.mozilla.org/en-US/docs/Web/CSS/:hover
382+ 'in-range' , // https://developer.mozilla.org/en-US/docs/Web/CSS/:in-range
383+ 'invalid' , // https://developer.mozilla.org/en-US/docs/Web/CSS/:invalid
384+ 'is' , // https://developer.mozilla.org/en-US/docs/Web/CSS/:is
385+ 'lang' , // https://developer.mozilla.org/en-US/docs/Web/CSS/:lang
386+ 'last-child' , // https://developer.mozilla.org/en-US/docs/Web/CSS/:last-child
387+ 'last-of-type' , // https://developer.mozilla.org/en-US/docs/Web/CSS/:last-of-type
388+ 'link' , // https://developer.mozilla.org/en-US/docs/Web/CSS/:link
389+ 'not' , // https://developer.mozilla.org/en-US/docs/Web/CSS/:not
390+ 'nth-child' , // https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-child
391+ 'nth-last-child' , // https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-last-child
392+ 'nth-last-of-type' , // https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-last-of-type
393+ 'nth-of-type' , // https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-of-type
394+ 'only-child' , // https://developer.mozilla.org/en-US/docs/Web/CSS/:only-child
395+ 'only-of-type' , // https://developer.mozilla.org/en-US/docs/Web/CSS/:only-of-type
396+ 'optional' , // https://developer.mozilla.org/en-US/docs/Web/CSS/:optional
397+ 'out-of-range' , // https://developer.mozilla.org/en-US/docs/Web/CSS/:out-of-range
398+ 'read-only' , // https://developer.mozilla.org/en-US/docs/Web/CSS/:read-only
399+ 'read-write' , // https://developer.mozilla.org/en-US/docs/Web/CSS/:read-write
400+ 'required' , // https://developer.mozilla.org/en-US/docs/Web/CSS/:required
401+ 'root' , // https://developer.mozilla.org/en-US/docs/Web/CSS/:root
402+ 'target' , // https://developer.mozilla.org/en-US/docs/Web/CSS/:target
403+ 'valid' , // https://developer.mozilla.org/en-US/docs/Web/CSS/:valid
404+ 'visited' , // https://developer.mozilla.org/en-US/docs/Web/CSS/:visited
405+ 'where' , // https://developer.mozilla.org/en-US/docs/Web/CSS/:where
406+ ] ) ;
0 commit comments