2016-08-25 8 views

答えて

2

DocumentインターフェイスのWebIDL定義の一部には、named property getterが指定されています。 the section of the spec of the HTML spec that defines the supported property names for the Document interfaceとの組み合わせでのみ意味があります。

これらは一緒に、Documentの名前付きプロパティとして公開されるものを指定します。

次のドキュメント考えてみましょう:あなたは、単一の要素、form name=foo要素が返されますdocument.foo呼び出す場合

<!doctype html> 
<form name=foo></form> 
<form name=bar></form> 
<iframe name=bar></iframe> 
<p id=baz> 

を。

document.barに電話すると、form name=bar要素とiframe name=bar要素の両方を含むコレクションが返されます。

document.bazに電話するとundefinedに戻ります。

すべてのその行動の理由は、section of the HTML spec defining the supported property names for the Document interfaceform[name]値とiframe[name]値はDocument

そしてthat spec sectionの名前付きプロパティとしてアクセス可能であることを指定されてもDocumentという名前のプロパティがあること、その後、一つだけの要素に一致した場合と言います要素が返されますが、複数の要素と一致する場合は、コレクションが返されます。 that spec sectionDocumentの名前付きプロパティとしてアクセス可能であるとしてp[id]値を指定していないためundefinedを返しdocument.baz

そして、理由があります。

window.bazの場合はとなります。の場合は、p id=bazの要素が返されます。

その違いの理由がある:WebIDL definition for Windowそれは(Document WebIDLと同じように)named property getterを有している指定しながら、Documentための同様のセクション-unlike section defining the supported property names for Windowからp[id]値(の実際id値を指定しません任意の要素)は、Windowの名前付きプロパティとしてアクセス可能であるとします。

関連する問題