TrustedTypePolicyFactory: emptyScript プロパティ
        
        
          Limited availability
        
        
        
          
                
              
                
              
                
              
        
        
      
      This feature is not Baseline because it does not work in some of the most widely-used browsers.
メモ: この機能はウェブワーカー内で利用可能です。
emptyScript は TrustedTypePolicyFactory インターフェイスの読み取り専用プロパティで、空文字列の入った TrustedScript オブジェクトを返します。
このオブジェクトは、アプリケーションが TrustedScript オブジェクトを期待する注入先に空の文字列を挿入する必要がある場合に使用できます。
値
TrustedScript オブジェクトです。
例
仕様では、 emptyScript オブジェクトを使用して動的コードコンパイルのサポートを検出できることが使用できます。
ネイティブの信頼型実装は eval(TrustedScript) を使用可能であるため、下記例ではネイティブ実装は eval(trustedTypes.emptyScript) に対して false を返します。ポリフィルは真値オブジェクトを返します。
js
const supportsTS = !eval(trustedTypes.emptyScript);
eval(supportsTS ? myTrustedScriptObj : myTrustedScriptObj.toString());
仕様書
| Specification | 
|---|
| Trusted Types> # dom-trustedtypepolicyfactory-emptyscript>  | 
            
ブラウザーの互換性
Loading…