upaa-selector version 2.0.1 をリリースしました

uupaa-js-spinoff uupaa-selector ver 2.0.1

BugFix版です。30以上の不具合を修正しています。

2009-02-11 追記 ::before の互換性について追記しました。

2.0 との違いは、

  • コードベースを uupaa.js 0.7 に変更しました。
    • uupaa-selector.js 単体で動作します。
  • :not を実装しました。
    • 一部の例外(namespace, :visited, :indeterminate)を除き、W3Cのテストスイートを全てパスするようになりました。
  • W3Cの細かな仕様をできるだけ盛り込みました。
    • CSS3で追加された擬似クラス(::before 等) を :before と記述するとエラーになります。 コロン(:)を一個追加して ::before としてください。(該当する仕様の記述については追記参照)
  • MutationEventによるキャッシュ機能は外しました。
  • jQuery独自セレクタなどは外しました。
  • :visited を切ってあります。その関係で、:visited と対の関係にある :link も一部仕様どおりに動作しません。

他のJavaScriptライブラリとの違いは、ご自分で確認してください。

速度テスト (テストが途中で止まる場合はリロードしてください)

ファイル一式

追記 ::before を :before と記述できない理由

before を :before と記述できない理由は「CSS 3で追加された擬似要素については下位互換性を持たせないこと」と明記されているためです。これは以下の仕様に該当します。

http://www.w3.org/TR/2005/WD-css3-selectors-20051215/#pseudo-elements
7. Pseudo-elements

Pseudo-elements create abstractions about the document tree beyond those specified by the document language. For instance, document languages do not offer mechanisms to access the first letter or first line of an element's content. Pseudo-elements allow designers to refer to this otherwise inaccessible information. Pseudo-elements may also provide designers a way to refer to content that does not exist in the source document (e.g., the ::before and ::after pseudo-elements give access to generated content).

A pseudo-element is made of two colons (::) followed by the name of the pseudo-element.


This :: notation is introduced by the current document in order to establish a discrimination between pseudo-classes and pseudo-elements. For compatibility with existing style sheets, user agents must also accept the previous one-colon notation for pseudo-elements introduced in CSS levels 1 and 2 (namely, :first-line, :first-letter, :before and :after). This compatibility is not allowed for the new pseudo-elements introduced in CSS level 3.

http://zng.info/specs/css3-selectors.html#pseudo-elements 参考までに旧版の日本語訳

7. 擬似要素

擬似要素は、文書言語によって指定されたものの範囲を超えて、文書ツリーに関する抽象概念を生成する。例えば、要素内容の最初の文字、あるいは最初の行にアクセスする仕組みを、文書言語は提供しない。擬似クラスはこのアクセスできない情報を設計者が参照するのを可能にする。また、擬似クラスはソース文書の中に存在しない内容を参照する方法も設計者に提供するかもしれない(例えば、::before及び::after擬似クラスは生成された内容へのアクセスを与える)。

擬似要素は、二つのコロン(::)とその次に続く擬似要素名からなる。

注: 擬似クラスと擬似要素の間の区別を重んじるために、当文書によってこの表記法::は導入される。また、既存のスタイルシートとの互換性のために、CSS水準1及び2で導入された擬似要素に対する以前の一コロンの表記法も、利用者エージェントは受け入れなければならない。この互換性は、CSS水準3において導入される新しい擬似要素に対しては許容されない

テストスイートにも以下のテスト項目が存在します。

  • Parsing : vs :: p:selection { color: yellow; background: red; } → マッチしないことを確認するテスト(エラーになり、該当するルール全体が無視されることを期待しているテスト)
  • Parsing : vs :: p::first-child { color: yellow; background: red; } → マッチすることを確認するテスト