querySelectorAll

古いブラウザ向けに、getElementsBySelector いわゆる querySelectorAll を実装しようと、色々と取り組んでいるんですが、いくつか問題が。

  • なんかきれいに実装できない。
    • "E + F" と "E ~ F" のFは先読みしたほうがいいのか、しないほうがいいのか
  • :first-line, :first-letter はどうする?
    • いっそのこと、先頭行, 先頭文字を<span>でくくった新しい要素を生成してしまうとか?

WebKitはどうやってんのかな? と思ったら、拡張子 y のファイルがそれでした。

今日一日で実装する予定だったのですが、なかなかに手ごわいです。
もうちょっとがんばってみます。

追記

div:first-of-type {
}

<div></div> ← 現在はこっちにマッチしてしまう。
<blockquote>
   <div>Does this element match?</div>
</blockquote>

The CSS selector should match the marked div element, because it is the first element of this type in this scope