1

Im having this real strange issue where IE8 isn't parsing my data attributes on the <body> tag.

For example, I have the following html:

<body data-controller="homeCtrl">

When i inspect the page in IE8 developer tools that attribute is completely missing. It is confirmed when i execute javascript in the console (it returns null!):

document.body.getAttribute('data-controller')

If i view the source, the data attribute is indeed there, IE8 just seems to ignore it or remove it?!?

More strangely, if i have a div within body.. for example

<div id="main" data-controller="homeCtrl">

This works! I can see it in the developer tools and I can read its value with javascript. So bizarre!

Has anyone come across this before? What would cause this to happen?

jennas
  • 2,444
  • 2
  • 25
  • 31
  • 1
    The tags you've given the question are confusing, so just to clarify: is this a real copy of IE8 that you're testing with, or a later version of IE running in IE8 compatibility mode? Also, since you specified the HTML5 tag, it's worth noting that IE8 doesn't know what HTML5 is; it was released long before HTML5 was invented. It should still understand data attributes as if they were normal HTML attributes though. – Spudley Oct 03 '15 at 10:08
  • I can't duplicate the behaviour you're describing. If I load a HTML file with `` into IE8 and type said JavaScript into the console, it returns "homeCtrl". – Mr Lister Oct 03 '15 at 10:48
  • Can you check if you have any non-printable characters in the start tag? – Mr Lister Oct 03 '15 at 10:54
  • Also, can you confirm what mode the browser is in? It might be standards mode, compatibility mode or quirks mode. If its anything other than standards mode, then that could be the cause of the problem, and either way is likely to give you other problems so needs to be fixed. – Spudley Oct 03 '15 at 14:34

0 Answers0