LoginSignup
0
0

More than 1 year has passed since last update.

Failed to execute 'setAttribute' on 'Element'

Posted at

はじめに

Angularで発生したFailed to execute 'setAttribute' on 'Element'について解決策をまとめた。

エラー

正直、エラー文から何が悪いのかわからなかった。

ERROR Error: Element' の 'setAttribute' の実行に失敗しました: ' type' は有効な属性名ではありません。

ERROR Error: Failed to execute 'setAttribute' on 'Element': ' type' is not a valid attribute name.

解決策

今回はinputタグのtypeの前に、全角を入力していたため、エラーになっていた。
htmlから全角の空白を取り除くことで解決した。

詳細なエラー文は異なるが、タイトルに示した本エラーが発生する条件として、以下のケースもあるようだ。
❌( click )→⭕️(click)
https://qiita.com/hedrall/items/4c95f6289031bb6946ab

対策

普段はVSCodeを使っており、全角/半角のスペースが検知され色がつくように設定している。
https://zenn.dev/ayatokura/articles/vscode-article-5

今回はWeb上での開発環境を使用していて、その環境に全角/半角のスペースが検知され色がつく設定をしていなかったので、全角スペースが入っていることをすぐにわからなかった。

おわりに

今回のような小さいエラーをなくすように、開発環境を整えていきたい。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0