Documentation

CustomElementBlocker extends AbstractPlugin
in package

Allows to block custom elements.

Tags
see
https://stackoverflow.com/a/22545622/5506547
see
https://html.spec.whatwg.org/multipage/custom-elements.html#custom-elements-customized-builtin-example)

Table of Contents

Constants

HTML_TAG_EXCLUDE  = ['font-face']

Properties

$customElements  : mixed
$headlessContentBlocker  : mixed

Methods

__construct()  : mixed
C'tor.
afterSetup()  : mixed
The content blocker got setup completely.
beforeMatch()  : mixed
Called before a match got found.
beforeSetBlockedInResult()  : bool
Allows to add an additional check before a blockable and expression gets added to a `BlockedResult`.
blockableStringExpression()  : string
Allows to modify the passed string expression to a blockable.
blockedMatch()  : mixed
See `AbstractPlugin`.
checkResult()  : BlockedResult
Called after a match got found and the matcher decided, if it should be blocked or not.
getHeadlessContentBlocker()  : mixed
Getter.
init()  : mixed
Initialize your plugin add e.g. new visual parent definitions.
inlineStyleBlockRule()  : bool
Decide if a URL in a CSS rule should be blocked.
inlineStyleModifyDocuments()  : bool
Allows to modify blocked CSS documents.
inlineStyleShouldBeExtracted()  : bool
Do not extract blocked rules of a CSS inline script to a second document.
iterateBlockablesInString()  : mixed
This method is run while iterating blockables and check if rules are found within a string.
keepAlwaysAttributes()  : array<string|int, string>
Keep attributes for a specific match.
modifyBlockables()  : array<string|int, AbstractBlockable>
Modify the blockables array before it gets registered.
modifyHtmlAfterProcessing()  : mixed
We are using multiple mechanisms to block custom elements, like selector syntax rule `SelectorSyntaxFinder` or `TagAttributeFinder`. At this time, the match is never a `TagWithContentMatch` and therefore we cannot simply use `->setTag()` in the above `blockedMatch` method. For this, we are setting an invisible attribute on the custom element which we are now cleaning up here and use the `TagWithContentFinder` to find the custom element and set the correct tag e.g. `<mui-avatar` to `<consent-mui-avatar>`.
notBlockedMatch()  : mixed
Called after a match got not blocked. Opposite of `blockedMatch`.
setup()  : mixed
Before the content blocker gets setup.
skipInlineScriptVariableAssignment()  : array<string|int, string>
Skip inline script by variable name.
visualParent()  : bool|string|number
Set a visual parent for a specific match.

Constants

Properties

Methods

afterSetup()

The content blocker got setup completely.

public afterSetup() : mixed
Tags
codeCoverageIgnore

blockableStringExpression()

Allows to modify the passed string expression to a blockable.

public blockableStringExpression(string $expression, AbstractBlockable $blockable) : string
Parameters
$expression : string
$blockable : AbstractBlockable
Tags
codeCoverageIgnore
Return values
string

getHeadlessContentBlocker()

Getter.

public final getHeadlessContentBlocker() : mixed

init()

Initialize your plugin add e.g. new visual parent definitions.

public init() : mixed

inlineStyleModifyDocuments()

Allows to modify blocked CSS documents.

public inlineStyleModifyDocuments(Document $document, Document $extractedDocument, StyleInlineMatcher|StyleInlineAttributeMatcher $matcher, StyleInlineMatch|StyleInlineAttributeMatch $match) : bool
Parameters
$document : Document
$extractedDocument : Document
$matcher : StyleInlineMatcher|StyleInlineAttributeMatcher
$match : StyleInlineMatch|StyleInlineAttributeMatch
Tags
codeCoverageIgnore
Return values
bool

iterateBlockablesInString()

This method is run while iterating blockables and check if rules are found within a string.

public iterateBlockablesInString(AbstractMatcher $matcher, BlockedResult $result, string $string, bool $useContainsRegularExpression, bool $multilineRegexp, array<string|int, string> $useRegularExpressionFromMap, array<string|int, AbstractBlockable$useBlockables, bool $allowMultiple) : mixed

It allows you to add additional blockables to the result even if isAllowMultipleBlockerResults is false.

Note: All required IDs from each matching Blockable will be merged together, but only the ID of the first Blockable found will be assigned as the consent-id of the element.

Parameters
$matcher : AbstractMatcher
$result : BlockedResult
$string : string
$useContainsRegularExpression : bool
$multilineRegexp : bool
$useRegularExpressionFromMap : array<string|int, string>
$useBlockables : array<string|int, AbstractBlockable>
$allowMultiple : bool
Tags
codeCoverageIgnore

keepAlwaysAttributes()

Keep attributes for a specific match.

public keepAlwaysAttributes(array<string|int, string> $keepAttributes, AbstractMatcher $matcher, AbstractMatch $match) : array<string|int, string>
Parameters
$keepAttributes : array<string|int, string>
$matcher : AbstractMatcher
$match : AbstractMatch
Tags
codeCoverageIgnore
Return values
array<string|int, string>

modifyHtmlAfterProcessing()

We are using multiple mechanisms to block custom elements, like selector syntax rule `SelectorSyntaxFinder` or `TagAttributeFinder`. At this time, the match is never a `TagWithContentMatch` and therefore we cannot simply use `->setTag()` in the above `blockedMatch` method. For this, we are setting an invisible attribute on the custom element which we are now cleaning up here and use the `TagWithContentFinder` to find the custom element and set the correct tag e.g. `<mui-avatar` to `<consent-mui-avatar>`.

public modifyHtmlAfterProcessing(string $html) : mixed
Parameters
$html : string

setup()

Before the content blocker gets setup.

public setup() : mixed
Tags
codeCoverageIgnore

skipInlineScriptVariableAssignment()

Skip inline script by variable name.

public skipInlineScriptVariableAssignment(array<string|int, string> $names, ScriptInlineMatcher $matcher, ScriptInlineMatch $match) : array<string|int, string>
Parameters
$names : array<string|int, string>
$matcher : ScriptInlineMatcher
$match : ScriptInlineMatch
Tags
codeCoverageIgnore
Return values
array<string|int, string>

visualParent()

Set a visual parent for a specific match.

public visualParent(bool|string|number $visualParent, AbstractMatcher $matcher, AbstractMatch $match) : bool|string|number
Parameters
$visualParent : bool|string|number
$matcher : AbstractMatcher
$match : AbstractMatch
Tags
codeCoverageIgnore
Return values
bool|string|number

        
On this page

Search results