Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE html>
<html>
<head>
<title>CSS Scoping Module Level 1 - :host, :host-context, and default @namespace</title>
<link rel="author" title="Rune Lillesveen" href="mailto:rune@opera.com"/>
<link rel="match" href="reference/green-box.html"/>
</head>
<body>
<style>
.host {
display: block;
width: 100px;
height: 10px;
background: red;
}
#host-3, #host-5, #host-10 {
background: green;
}
</style>
<p>Test passes if you see a single 100px by 100px green box below.</p>
<div id="host-1" class="host">FAIL</div>
<div id="host-2" class="host">FAIL</div>
<div id="host-3" class="host">FAIL</div>
<div id="host-4" class="host">FAIL</div>
<div id="host-5" class="host">FAIL</div>
<div id="host-6" class="host">FAIL</div>
<div id="host-7" class="host">FAIL</div>
<div id="host-8" class="host">FAIL</div>
<div id="host-9" class="host">FAIL</div>
<div id="host-10" class="host">FAIL</div>
<script>
try {
var shadowHost = document.querySelector('#host-1');
shadowRoot = shadowHost.attachShadow({mode: 'open'});
shadowRoot.innerHTML = '<style>@namespace url(http://www.w3.org/1999/xhtml); :host { background: green !important; } </style>';
shadowHost = document.querySelector('#host-2');
shadowRoot = shadowHost.attachShadow({mode: 'open'});
shadowRoot.innerHTML = '<style>@namespace url(http://dummy); :host { background: green !important; } </style>';
shadowHost = document.querySelector('#host-3');
shadowRoot = shadowHost.attachShadow({mode: 'open'});
shadowRoot.innerHTML = '<style>@namespace url(http://dummy); :host(*) { background: red !important; } </style>';
shadowHost = document.querySelector('#host-4');
shadowRoot = shadowHost.attachShadow({mode: 'open'});
shadowRoot.innerHTML = '<style>@namespace url(http://dummy); :host(*|*) { background: green !important; } </style>';
shadowHost = document.querySelector('#host-5');
shadowRoot = shadowHost.attachShadow({mode: 'open'});
shadowRoot.innerHTML = '<style>@namespace url(http://dummy); :host-context(*) { background: red !important; } </style>';
shadowHost = document.querySelector('#host-6');
shadowRoot = shadowHost.attachShadow({mode: 'open'});
shadowRoot.innerHTML = '<style>@namespace url(http://dummy); :host-context(*|*) { background: green !important; } </style>';
shadowHost = document.querySelector('#host-7');
shadowRoot = shadowHost.attachShadow({mode: 'open'});
shadowRoot.innerHTML = '<style>@namespace url(http://www.w3.org/1999/xhtml); :host(*) { background: green !important; } </style>';
shadowHost = document.querySelector('#host-8');
shadowRoot = shadowHost.attachShadow({mode: 'open'});
shadowRoot.innerHTML = '<style>@namespace url(http://www.w3.org/1999/xhtml); :host-context(*) { background: green !important; } </style>';
shadowHost = document.querySelector('#host-9');
shadowRoot = shadowHost.attachShadow({mode: 'open'});
shadowRoot.innerHTML = '<style>@namespace url(http://www.w3.org/1999/xhtml); :host(div) { background: green !important; } </style>';
shadowHost = document.querySelector('#host-10');
shadowRoot = shadowHost.attachShadow({mode: 'open'});
shadowRoot.innerHTML = '<style>@namespace url(http://dummy); :host-context(html) { background: red !important; } </style>';
} catch (exception) {
document.body.appendChild(document.createTextNode(exception));
}
</script>
</body>
</html>