Skip to content

Commit a3272e6

Browse files
committed
Move the entry point of the API to the window.navigator interface.
Closes #67
1 parent fb2d39d commit a3272e6

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ Among the values that the device-posture query can take are:
4040
/*for a monitor scenario*/
4141
@media (device-posture: flat) and (orientation: portrait) { ... }
4242
```
43-
### New JS object in `window.screen`: `posture`
43+
### New JS object in `window.navigator`: `devicePosture`
4444

45-
The Window property screen returns a reference to the screen object associated with the window. It already houses a similar property [`orientation`](https://developer.mozilla.org/en-US/docs/Web/API/ScreenOrientation) that itself has a value for an [angle](https://w3c.github.io/screen-orientation/#idl-index).
45+
The Navigator property of Window [navigator](https://html.spec.whatwg.org/multipage/system-state.html#the-navigator-object) should host device capabilities and system states.
4646

4747
#### Proposed Object
4848
```javascript

index.html

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -132,18 +132,18 @@ <h2>
132132
provide a different layout for it depending on the posture state in which the device is being used.
133133
</p>
134134
</section>
135-
<section data-dfn-for="Screen">
135+
<section data-dfn-for="Navigator">
136136
<h2>
137-
Extensions to the `Screen` interface
137+
Extensions to the `Navigator` interface
138138
</h2>
139139
<p>
140-
The [[cssom-view]] specification defines the <dfn>Screen</dfn> interface,
140+
The [[HTML]] specification defines the <dfn>Navigator</dfn> interface,
141141
which this specification extends:
142142
</p>
143143
<pre class="idl">
144-
[SecureContext]
145-
partial interface Screen {
146-
[SameObject] readonly attribute DevicePosture posture;
144+
[SecureContext, Exposed=(Window)]
145+
partial interface Navigator {
146+
[SameObject] readonly attribute DevicePosture devicePosture;
147147
};
148148
</pre>
149149
</section>
@@ -508,7 +508,7 @@ <h2>
508508
</li>
509509
<li>
510510
<a>Fire an event</a> named `change` at |document|'s
511-
{{Screen.posture}} object.
511+
{{Window.navigator.devicePosture}} object.
512512
</li>
513513
</ol>
514514
</li>
@@ -535,14 +535,14 @@ <h2>
535535
<ol>
536536
<li>
537537
<a>Fire an event</a> named `change` at the |document|'s
538-
{{Screen.posture}} object.
538+
{{Window.navigator.devicePosture}} object.
539539
</li>
540540
</ol>
541541
</li>
542542
</ol>
543543
<div class="note">
544544
<p>
545-
Developers need to be aware that a {{Screen.posture}} object
545+
Developers need to be aware that a {{Window.navigator.devicePosture}} object
546546
from a <a>document</a> that is not visible, as per
547547
[[PAGE-VISIBILITY]], will not receive an orientation change event.
548548
This is to prevent unnecessary changes to layout, etc. in the
@@ -640,8 +640,8 @@ <h2>
640640
<h3>Example 1: Posture data</h3>
641641
<p>This is a simple use case of the <a>posture</a> being printed on the console. </p>
642642
<pre class="example js" title="React to poster change">
643-
screen.posture.addEventListener("change", () => {
644-
console.log(`The current posture is: ${screen.posture.type}!`);
643+
navigator.devicePosture.addEventListener("change", () => {
644+
console.log(`The current posture is: ${navigator.devicePosture.type}!`);
645645
})
646646
</pre>
647647
<h3>Example 2: device-posture</h3>

0 commit comments

Comments
 (0)