Skip to content

Commit

Permalink
add aliases 'shadowRoot' and 'createShadowRoot' for the prefixed prop…
Browse files Browse the repository at this point in the history
…erties
  • Loading branch information
Scott Miles committed Jun 11, 2013
1 parent 015be2e commit 9ad15c9
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 8 deletions.
15 changes: 12 additions & 3 deletions lib/patches-shadowdom-native.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,18 @@
return n;
}

window.createShadowRoot = function(inElement) {
return inElement.webkitCreateShadowRoot();
};
Object.defineProperties(HTMLElement.prototype, {
shadowRoot: {
get: function() {
return this.webkitShadowRoot;
}
},
createShadowRoot: {
value: function() {
return this.webkitCreateShadowRoot();
}
}
});

window.templateContent = function(inTemplate) {
// if MDV exists, it may need to boostrap this template to reveal content
Expand Down
2 changes: 1 addition & 1 deletion test/html/includes/strawkit.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Polymer = {
inPrototype.readyCallback = function() {
var template = inElement.querySelector('template');
if (template) {
var root = this.webkitCreateShadowRoot();
var root = this.createShadowRoot();
root.appendChild(templateContent(template).cloneNode(true));
}
inPrototype.created.call(this);
Expand Down
2 changes: 1 addition & 1 deletion test/html/smoke.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<meta charset="UTF-8">
<script src="../../tools/test/htmltest.js"></script>
<script src="../../node_modules/chai/chai.js"></script>
<script src="../../platform.js"></script>
<script src="../../platform.js" debug></script>
</head>
<body>
<x-foo>plain</x-foo>
Expand Down
3 changes: 2 additions & 1 deletion test/html/strawkit.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<script src="../../tools/test/htmltest.js"></script>
<script src="../../node_modules/chai/chai.js"></script>
<!-- -->
<script src="../../platform.js"></script>
<script src="../../platform.js" debug></script>
<script src="includes/strawkit.js"></script>
</head>
<body>
Expand Down Expand Up @@ -40,6 +40,7 @@
'x-foo has wrong textContent');
assert.match(elt.style.backgroundColor, /lightblue|rgb\(173, 216, 230\)/,
'x-foo has wrong backgroundColor');
assert.ok(elt.shadowRoot, 'shadowRoot not available as `.shadowRoot`');
done();
});
</script>
Expand Down
2 changes: 1 addition & 1 deletion test/html/template-distribute.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

function createShadowRoot(node) {
return window.ShadowDOMPolyfill ? node.createShadowRoot() :
node.webkitCreateShadowRoot();
node.createShadowRoot();
}

document.addEventListener('DOMContentLoaded', function() {
Expand Down
2 changes: 1 addition & 1 deletion test/html/web-components.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<meta charset="UTF-8">
<script src="../../tools/test/htmltest.js"></script>
<script src="../../node_modules/chai/chai.js"></script>
<script src="../../platform.min.js"></script>
<script src="../../platform.js" debug></script>
<link rel="import" href="includes/import-file.html">
</head>
<body>
Expand Down

0 comments on commit 9ad15c9

Please sign in to comment.