Skip to content

Commit c444bc4

Browse files
kylekatarnlsmarcj
authored andcommitted
Simplify else statements (marcj#147)
1 parent 05c98b5 commit c444bc4

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/ResizeSensor.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,12 @@
100100
function getComputedStyle(element, prop) {
101101
if (element.currentStyle) {
102102
return element.currentStyle[prop];
103-
} else if (window.getComputedStyle) {
103+
}
104+
if (window.getComputedStyle) {
104105
return window.getComputedStyle(element, null).getPropertyValue(prop);
105-
} else {
106-
return element.style[prop];
107106
}
107+
108+
return element.style[prop];
108109
}
109110

110111
/**
@@ -113,14 +114,14 @@
113114
* @param {Function} resized
114115
*/
115116
function attachResizeEvent(element, resized) {
116-
if (!element.resizedAttached) {
117-
element.resizedAttached = new EventQueue();
118-
element.resizedAttached.add(resized);
119-
} else if (element.resizedAttached) {
117+
if (element.resizedAttached) {
120118
element.resizedAttached.add(resized);
121119
return;
122120
}
123121

122+
element.resizedAttached = new EventQueue();
123+
element.resizedAttached.add(resized);
124+
124125
element.resizeSensor = document.createElement('div');
125126
element.resizeSensor.className = 'resize-sensor';
126127
var style = 'position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: hidden; z-index: -1; visibility: hidden;';

0 commit comments

Comments
 (0)