-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexercise5.js
More file actions
25 lines (18 loc) · 862 Bytes
/
exercise5.js
File metadata and controls
25 lines (18 loc) · 862 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// templateを表示させる
// var template = document.getElementById('ex-template');
// var templateContent = template.content;
// document.body.appendChild(templateContent);
var templete = document.getElementById('sample-template').content.cloneNode(true);
var host = document.getElementById('sample');
var root = host.attachShadow({mode: 'open'});
root.appendChild(templete);
// cloneNode(true):現在のcontentの複製とその子孫の複製を返す
// attachShadow:要素にShadow DOMを関連付けるメゾット
// 'open':シャドウルートに外部のJavaScriptからアクセスできるようにする
window.addEventListener("orientationchange", function() {
if(screen.orientation.angle === 0){
host.style.border = '50px solid coral';
} else {
host.style.border = '50px solid cadetblue';
}
});