Skip to content

Commit cfeecca

Browse files
committed
Rename .open to .isOpen
1 parent 5e78921 commit cfeecca

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ declare namespace devTools {
77
/**
88
Whether DevTools is open.
99
*/
10-
readonly open: boolean;
10+
readonly isOpen: boolean;
1111

1212
/**
1313
Orientation of the DevTools if it's open.

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@ <h3 id="devtools-orientation"></h3>
7878
const stateElement = document.querySelector('#devtools-state');
7979
const orientationElement = document.querySelector('#devtools-orientation');
8080

81-
stateElement.textContent = window.devtools.open ? 'yes' : 'no';
81+
stateElement.textContent = window.devtools.isOpen ? 'yes' : 'no';
8282
orientationElement.textContent = window.devtools.orientation ? window.devtools.orientation : '';
8383

8484
window.addEventListener('devtoolschange', event => {
85-
stateElement.textContent = event.detail.open ? 'yes' : 'no';
85+
stateElement.textContent = event.detail.isOpen ? 'yes' : 'no';
8686
orientationElement.textContent = event.detail.orientation ? event.detail.orientation : '';
8787
});
8888
</script>

index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ MIT License
99
'use strict';
1010

1111
const devtools = {
12-
open: false,
12+
isOpen: false,
1313
orientation: undefined
1414
};
1515

1616
const threshold = 160;
1717

18-
const emitEvent = (state, orientation) => {
18+
const emitEvent = (isOpen, orientation) => {
1919
window.dispatchEvent(new CustomEvent('devtoolschange', {
2020
detail: {
21-
open: state,
21+
isOpen,
2222
orientation
2323
}
2424
}));
@@ -33,18 +33,18 @@ MIT License
3333
!(heightThreshold && widthThreshold) &&
3434
((window.Firebug && window.Firebug.chrome && window.Firebug.chrome.isInitialized) || widthThreshold || heightThreshold)
3535
) {
36-
if (!devtools.open || devtools.orientation !== orientation) {
36+
if (!devtools.isOpen || devtools.orientation !== orientation) {
3737
emitEvent(true, orientation);
3838
}
3939

40-
devtools.open = true;
40+
devtools.isOpen = true;
4141
devtools.orientation = orientation;
4242
} else {
43-
if (devtools.open) {
43+
if (devtools.isOpen) {
4444
emitEvent(false, undefined);
4545
}
4646

47-
devtools.open = false;
47+
devtools.isOpen = false;
4848
devtools.orientation = undefined;
4949
}
5050
}, 500);

index.test-d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import {expectType} from 'tsd';
22
import devtools = require('.');
33

4-
expectType<boolean>(devtools.open);
4+
expectType<boolean>(devtools.isOpen);
55
expectType<devtools.Orientation | undefined>(devtools.orientation);
66

77
window.addEventListener('devtoolschange', devtoolsEvent => {
88
expectType<devtools.DevToolsEvent>(devtoolsEvent);
9-
expectType<boolean>(devtoolsEvent.detail.open);
9+
expectType<boolean>(devtoolsEvent.detail.isOpen);
1010
expectType<devtools.Orientation | undefined>(devtoolsEvent.detail.orientation);
1111
});

readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ $ npm install devtools-detect
2121
<script src="node_modules/devtools-detect/index.js"></script>
2222
<script type="module">
2323
// Check if it's open
24-
console.log('Is DevTools open:', window.devtools.open);
24+
console.log('Is DevTools open:', window.devtools.isOpen);
2525
2626
// Check it's orientation, `undefined` if not open
2727
console.log('DevTools orientation:', window.devtools.orientation);
2828
2929
// Get notified when it's opened/closed or orientation changes
3030
window.addEventListener('devtoolschange', event => {
31-
console.log('Is DevTools open:', event.detail.open);
31+
console.log('Is DevTools open:', event.detail.isOpen);
3232
console.log('DevTools orientation:', event.detail.orientation);
3333
});
3434
</script>

0 commit comments

Comments
 (0)