Skip to main content

selector_syntax_error

Function selector_syntax_error 

Source
pub fn selector_syntax_error(sel: &str) -> bool
Expand description

セレクタ文字列が構文として無効(querySelector・matches・closest が SyntaxError を投げるべき)か。 確実に無効と言えるものだけを判定し、それ以外は従来どおり寛容に解析させる:

  • #・. の後ろが識別子で始まらない(#-123・.-123・#1・. だけ)。CSS Syntax §4.3.9。
  • 名前空間接頭辞の付いた型・属性(cp|tag・[xml|lang])。querySelector は名前空間を宣言できない (*|・| だけは可)。Selectors Level 4 §6.3・§16。

:is()/:where() の中は寛容な(forgiving)セレクタ一覧なので検査しない。:nth-child() 等の セレクタでない引数の中も検査しない。