次のコードは、IE9 で型の不一致エラーを返します。
node.setAttribute('attributeName',null);
しかし
node.setAttribute('attributeName',undefined) doesn't give an error.
そして、これも問題ありません:
node.setAttribute('attributeName','null');
なぜこれが起こっているのか、それを修正する良い方法は何ですか。
1つの解決策は、確認することです。
if (attributeVal === null){
attributeVal = 'null';
},
node.setAttribute('attributeName',attributeVal);
助言がありますか ?