aspnet / BrowserLink

Browser Link loader for Visual Studio integration

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BrowserLink changes document structure unexpectedly

SteveSandersonMS opened this issue · comments

The default ASP.NET Core MVC site template, when viewed in the Chrome "Elements" inspector, looks like this:

screen shot 2016-05-09 at 18 27 32

However, if BrowserLink is enabled, it looks like this:

screen shot 2016-05-09 at 18 28 08

Obviously, the addition of the <!-- Visual Studio Browser Link --> block is correct, but the other changes are unexpected:

  • Why has everything from <head> been moved into <body>?
  • Why is <body> prefixed with the nonbreaking whitespace char (&#65279;)?

The answer to "Why has everything from <head> been moved into <body> ?" is probably that the Chrome "Elements" inspector is showing a representation of the DOM, rather than the raw HTML that was rendered by the server. When there's text content before the <head> or <html> tags, browsers typically treat that as the beginning of the body, regardless of where the <body> tag is.

So the real question is, where did that extra nonbreaking whitespace come from? That I don't know. It sounds like I should be able to reproduce this easily, so I will debug into it.

@SteveSandersonMS Do you have any Browser Link extensions installed (e.g. Web Essentials)?

@SteveSandersonMS I'm not able to reproduce this. What version of Web Tools and ASP.NET Core are you using? Did you make any other changes to the project?

Turns out this is happening because Browser Link is incorrectly emitting a BOM at the beginning of the page, and Chrome is interpreting the extra bytes as text characters.

The general BOM issue is being tracked by this issue: #24