aFarkas / html5shiv

This script is the defacto way to enable use of HTML5 sectioning elements in legacy Internet Explorer.
http://paulirish.com/2011/the-history-of-the-html5-shiv/
9.89k stars 2.56k forks source link

Presence of xmlns attribute causes HTML5Shiv to Fail in IE8 #167

Open zacharybrady opened 10 years ago

zacharybrady commented 10 years ago

Presence of the xmlns attribute causes the HTML5Shiv to fail.

Example instance: In the

Volker-E commented 10 years ago

The SO question seems different, as the Operator stated

one of the nav elements had an odd attribute xmlns="http://www.w3.org/1999/html" assigned to it causing the error.

Putting xmlns attributes on HTML5 elements aside of root and assuming that they'll work as intended doesn't look like a great idea. But this haven't caused your issue, right?

aFarkas commented 10 years ago

Unfortunaley, I can't really replicate this issue using standard conform markup. This is my HTML:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
<head>
    <meta charset="utf-8" />
    <title></title>
    <style>
        section {
            margin: 10px;
            padding: 10px;
            border: 3px solid #000;
        }

        svg section,
        section section {
            border-color: red;
        }
    </style>
    <script src="../src/html5shiv-printshiv.js"></script>
</head>
<body>
<section>
    test
</section>
<section>
    test
<svg width="400" height="110" xmlns="http://www.w3.org/2000/svg">
     <rect width="300" height="100" style="fill:rgb(0,0,255);stroke-width:3;stroke:rgb(0,0,0)" />
</svg>
</section>
<section>test</section>
<script>
    if(document.querySelectorAll){
        var section = document.querySelectorAll('section');
        for(var i = 0; i < section.length; i++){
            console.log(section[i].parentNode)
        }
    }
</script>
</body>
</html>

The only way I can replicate that something is going wrong is by using a) a namespace (polyglot HTML5) and b) do not explicitly close the rect element.

jessekeyes commented 10 years ago

I had the same issue and it was the xmlns attribute in an inline SVG file (in the ). Even though IE8 isn't supposed to recognize SVGs... removing xmlns from the allowed the shiv to work correctly.