Skip Navigation
Type MethodMethod

selector(forAnchor:)

Returns a selector that matches the element with the given identifier.

static func selector(forAnchor anchor: String) -> String

Parameters

anchor

The identifier of the section heading.

Return Value

An attribute selector.

Discussion

The identifier becomes a CSS string serialised like CSSOM’s “serialize a string”: a null character becomes U+FFFD, control characters (including line feeds, carriage returns and form feeds) become hexadecimal escapes, and quotation marks and backslashes are escaped. A < also becomes a hexadecimal escape, so the selector cannot end the <style> element that contains it. Any identifier is therefore matched exactly.