Skip to content
This repository was archived by the owner on Aug 5, 2020. It is now read-only.

Commit cff793d

Browse files
author
Steve Calvert
committed
Removed the setTimeout in the test. We don't need this because we're never animating when this call fires. Also removed the redundant _item function calls in the _isOpen and _isDisabled functions
1 parent c201449 commit cff793d

File tree

4 files changed

+37
-51
lines changed

4 files changed

+37
-51
lines changed

dist/bellows.js

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@
6767
/**
6868
* Ghetto Event Delegation™
6969
70-
Zepto doesn't support descendant selectors in event delegation,
71-
so we compare against the closest bellows to ensure we are invoking
72-
the event from a direct child, not a bellows child from a nested bellows.
70+
Zepto doesn't support descendant selectors in event delegation,
71+
so we compare against the closest bellows to ensure we are invoking
72+
the event from a direct child, not a bellows child from a nested bellows.
7373
*/
7474
this.$bellows
7575
.on(events.CLICK, function(e) {
@@ -118,6 +118,14 @@
118118
return item;
119119
},
120120

121+
_isOpen: function($item) {
122+
return $item.hasClass(cssClasses.OPENED);
123+
},
124+
125+
_isDisabled: function($item) {
126+
return $item.hasClass(cssClasses.DISABLED);
127+
},
128+
121129
_wrapContent: function($items) {
122130
$items
123131
.find(selectors.ITEM_CONTENT)
@@ -129,18 +137,6 @@
129137
.attr('aria-hidden', true);
130138
},
131139

132-
/*
133-
Helper methods for determining Bellows item's status
134-
*/
135-
_isOpen: function($item) {
136-
$item = this._item($item);
137-
return $item.hasClass(cssClasses.OPENED);
138-
},
139-
_isDisabled: function($item) {
140-
$item = this._item($item);
141-
return $item.hasClass(cssClasses.DISABLED);
142-
},
143-
144140
toggle: function($item) {
145141
$item = this._item($item);
146142

@@ -161,7 +157,7 @@
161157
this.closeAll();
162158
}
163159

164-
this._trigger('open', { item: $item });
160+
this._trigger('open', {item: $item});
165161

166162
Velocity
167163
.animate($contentWrapper, 'slideDown', {
@@ -180,7 +176,7 @@
180176

181177
plugin._setHeight();
182178

183-
plugin._trigger('opened', { item: $item });
179+
plugin._trigger('opened', {item: $item});
184180
}
185181
});
186182
},
@@ -195,7 +191,7 @@
195191
var plugin = this;
196192
var $contentWrapper = $item.find(selectors.ITEM_CONTENT_WRAPPER);
197193

198-
this._trigger('close', { item: $item });
194+
this._trigger('close', {item: $item});
199195

200196
Velocity
201197
.animate($contentWrapper, 'slideUp', {
@@ -215,7 +211,7 @@
215211

216212
plugin._setHeight();
217213

218-
plugin._trigger('closed', { item: $item });
214+
plugin._trigger('closed', {item: $item});
219215
}
220216
});
221217
},

dist/bellows.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/js/bellows.js

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@
6767
/**
6868
* Ghetto Event Delegation™
6969
70-
Zepto doesn't support descendant selectors in event delegation,
71-
so we compare against the closest bellows to ensure we are invoking
72-
the event from a direct child, not a bellows child from a nested bellows.
70+
Zepto doesn't support descendant selectors in event delegation,
71+
so we compare against the closest bellows to ensure we are invoking
72+
the event from a direct child, not a bellows child from a nested bellows.
7373
*/
7474
this.$bellows
7575
.on(events.CLICK, function(e) {
@@ -118,6 +118,14 @@
118118
return item;
119119
},
120120

121+
_isOpen: function($item) {
122+
return $item.hasClass(cssClasses.OPENED);
123+
},
124+
125+
_isDisabled: function($item) {
126+
return $item.hasClass(cssClasses.DISABLED);
127+
},
128+
121129
_wrapContent: function($items) {
122130
$items
123131
.find(selectors.ITEM_CONTENT)
@@ -129,18 +137,6 @@
129137
.attr('aria-hidden', true);
130138
},
131139

132-
/*
133-
Helper methods for determining Bellows item's status
134-
*/
135-
_isOpen: function($item) {
136-
$item = this._item($item);
137-
return $item.hasClass(cssClasses.OPENED);
138-
},
139-
_isDisabled: function($item) {
140-
$item = this._item($item);
141-
return $item.hasClass(cssClasses.DISABLED);
142-
},
143-
144140
toggle: function($item) {
145141
$item = this._item($item);
146142

@@ -161,7 +157,7 @@
161157
this.closeAll();
162158
}
163159

164-
this._trigger('open', { item: $item });
160+
this._trigger('open', {item: $item});
165161

166162
Velocity
167163
.animate($contentWrapper, 'slideDown', {
@@ -180,7 +176,7 @@
180176

181177
plugin._setHeight();
182178

183-
plugin._trigger('opened', { item: $item });
179+
plugin._trigger('opened', {item: $item});
184180
}
185181
});
186182
},
@@ -195,7 +191,7 @@
195191
var plugin = this;
196192
var $contentWrapper = $item.find(selectors.ITEM_CONTENT_WRAPPER);
197193

198-
this._trigger('close', { item: $item });
194+
this._trigger('close', {item: $item});
199195

200196
Velocity
201197
.animate($contentWrapper, 'slideUp', {
@@ -215,7 +211,7 @@
215211

216212
plugin._setHeight();
217213

218-
plugin._trigger('closed', { item: $item });
214+
plugin._trigger('closed', {item: $item});
219215
}
220216
});
221217
},

tests/unit/plugin.js

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ define([
252252
});
253253

254254
describe('disabling a bellows item', function() {
255-
it('does not open item when header clicked', function(done) {
255+
it('does not open item when header clicked', function() {
256256
$element.bellows();
257257

258258
var $disabledItem = $(disabledItem);
@@ -263,14 +263,11 @@ define([
263263
.find('.bellows__header')
264264
.trigger('click');
265265

266-
setTimeout(function() {
267-
expect($disabledItem.hasClass('bellows--is-disabled')).to.be.true;
268-
expect($disabledItem.hasClass('bellows--is-open')).to.be.false;
269-
done();
270-
});
266+
expect($disabledItem.hasClass('bellows--is-disabled')).to.be.true;
267+
expect($disabledItem.hasClass('bellows--is-open')).to.be.false;
271268
});
272269

273-
it('does not close item when header clicked', function(done) {
270+
it('does not close item when header clicked', function() {
274271
$element.bellows();
275272

276273
var $openDisabledItem = $(openDisabledItem);
@@ -281,11 +278,8 @@ define([
281278
.find('.bellows__header')
282279
.trigger('click');
283280

284-
setTimeout(function() {
285-
expect($openDisabledItem.hasClass('bellows--is-disabled')).to.be.true;
286-
expect($openDisabledItem.hasClass('bellows--is-open')).to.be.true;
287-
done();
288-
});
281+
expect($openDisabledItem.hasClass('bellows--is-disabled')).to.be.true;
282+
expect($openDisabledItem.hasClass('bellows--is-open')).to.be.true;
289283
});
290284
});
291285
});

0 commit comments

Comments
 (0)