Skip to content

Commit 0d14537

Browse files
ishanrayFezVrasta
authored andcommitted
Improved undefined type check and improved documentation
* Update popper.js * Undefined test and contributing updates. 1. Check for undefined using typeof as the other way may throw an error. 2. The bower install is also a very important part of the setup requirements and should be mentioned. 3. Bringing the preexisting conditions before the actual install makes it easier to follow. * Update undefined test
1 parent 44be295 commit 0d14537

3 files changed

Lines changed: 18 additions & 6 deletions

File tree

CONTRIBUTING.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ Feature requests are welcome!
1111

1212
## Setup
1313

14-
In order to properly work on the development environment, run:
14+
Make sure to have `grunt-cli` and `bower` installed globally.
15+
16+
Then run:
1517

1618
```js
1719
npm install
20+
bower install
1821
```
1922

20-
and make sure to have `grunt-cli` and `bower` installed globally.
21-
2223
## Developing
2324

2425
We develop following a test driven development approach.

src/popper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@
139139

140140
// if the popper variable is a configuration object, parse it to generate an HTMLElement
141141
// generate a default popper if is not defined
142-
var isNotDefined = popper === undefined || popper === null;
142+
var isNotDefined = typeof popper === 'undefined' || popper === null;
143143
var isConfig = popper && popper.constructor.name === 'Object';
144-
if ( isNotDefined || isConfig) {
144+
if (isNotDefined || isConfig) {
145145
this._popper = this.parse(isConfig ? popper : {});
146146
}
147147
// otherwise, use the given HTMLElement as popper

tests/test-popper.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ describe('Popper.js', function() {
112112
var relative = document.createElement('div');
113113
relative.style.position = 'relative';
114114
relative.style.margin = '20px';
115-
relative.style.height = '200vh';
115+
relative.style.height = '300vh';
116116
jasmineWrapper.appendChild(relative);
117117
document.body.scrollTop = 800;
118118

@@ -234,4 +234,15 @@ describe('Popper.js', function() {
234234
done();
235235
});
236236
});
237+
238+
it('creates a popper when content is undefined', function(done) {
239+
var reference = appendNewRef(1);
240+
241+
new TestPopper(reference).onCreate(function(instance) {
242+
expect(instance._popper).toBeDefined();
243+
expect(instance._popper.innerText).toBe('');
244+
document.body.removeChild(instance._popper);
245+
done();
246+
});
247+
});
237248
});

0 commit comments

Comments
 (0)