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!
}
サポートされているオプションのリストが増えたり変更されたりしても、特徴検出を使用して、ウェブ アプリケーションに適したアクションを実行できます。