Chrome 50 では、JavaScript の DOMTokenList
インスタンスに基づく一部の HTML 属性に対するオプションのサポートを確認できるようになります。
現在、以下の場所があります。
- iframe サンドボックスのオプション
- リンクの関係(rel 属性、または JavaScript では relLink)
簡単な例を見てみましょう。
var iframe = document.getElementById(...);
if (iframe.sandbox.supports('an-upcoming-feature')) {
// support code for mystery future feature
} else {
// fallback code
}
if (iframe.sandbox.supports('allow-scripts')) {
// instruct frame to run JavaScript
// NOTE: this is well-supported, and just an example!
}
サポートされるオプションのリストが拡大または変更された場合、機能検出を使用して、ウェブ アプリケーションに対して適切なアクションを実行できます。