Erik
Erik

Reputation: 3636

Forcing the Chrome Inspector to show the real source code instead of its interpretation of it

The Chrome Inspector is pretty neat when looking at your HTML/JS in an application, but a few times now I have noticed that it does not display the real source, but rather shows you how it has interpreted your page.

This will occasionally make things complicated or confusing, because a bug is actually caused by a behavior that the inspector refuses to show and instead requires you to look at the page through View Source to see.

For example, if you nest two forms (which is illegal in html) then the inspector will instead show that it's closing the first form before opening the second one, which makes it look like everything is okay.

I've also seen it remove attributes that it doesn't understand, swap out quotation marks for different ones, and do some more odd things that complicate the life of a debugging programmer.

Is there any way to turn this feature off and force the inspector to show you what it has really been reading?

Upvotes: 0

Views: 294

Answers (1)

ikkentim
ikkentim

Reputation: 1648

The inspector doesn't show the HTML source of the page, instead it show the HTML representation of the current DOM. When the HTML is initially parsed and validates and fixes it before building the DOM. At that time errors such as nested forms are solved. If you wish to view the original source of a page, right click the page and select view source.

Upvotes: 1

Related Questions