-
-
Notifications
You must be signed in to change notification settings - Fork 470
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: hot module replacement for css modules
- Loading branch information
1 parent
26bfaa5
commit 6d14e0a
Showing
3 changed files
with
142 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
function isEqualLocals(a, b) { | ||
if ((!a && b) || (a && !b)) { | ||
return false; | ||
} | ||
|
||
let p; | ||
|
||
for (p in a) { | ||
if (a[p] !== b[p]) { | ||
return false; | ||
} | ||
} | ||
|
||
for (p in b) { | ||
if (!a[p]) { | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
|
||
module.exports = isEqualLocals; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* eslint-env browser */ | ||
|
||
import isEqualLocals from '../../src/runtime/isEqualLocals'; | ||
|
||
describe('isEqualLocals', () => { | ||
it('should work', () => { | ||
expect(isEqualLocals()).toBe(true); | ||
expect(isEqualLocals({}, {})).toBe(true); | ||
// eslint-disable-next-line no-undefined | ||
expect(isEqualLocals(undefined, undefined)).toBe(true); | ||
expect(isEqualLocals({ foo: 'bar' }, { foo: 'bar' })).toBe(true); | ||
expect( | ||
isEqualLocals({ foo: 'bar', bar: 'baz' }, { foo: 'bar', bar: 'baz' }) | ||
).toBe(true); | ||
expect( | ||
isEqualLocals({ foo: 'bar', bar: 'baz' }, { bar: 'baz', foo: 'bar' }) | ||
).toBe(true); | ||
expect( | ||
isEqualLocals({ bar: 'baz', foo: 'bar' }, { foo: 'bar', bar: 'baz' }) | ||
).toBe(true); | ||
|
||
// eslint-disable-next-line no-undefined | ||
expect(isEqualLocals(undefined, { foo: 'bar' })).toBe(false); | ||
// eslint-disable-next-line no-undefined | ||
expect(isEqualLocals({ foo: 'bar' }, undefined)).toBe(false); | ||
|
||
expect(isEqualLocals({ foo: 'bar' }, { foo: 'baz' })).toBe(false); | ||
|
||
expect(isEqualLocals({ foo: 'bar' }, { bar: 'bar' })).toBe(false); | ||
expect(isEqualLocals({ bar: 'bar' }, { foo: 'bar' })).toBe(false); | ||
|
||
expect(isEqualLocals({ foo: 'bar' }, { foo: 'bar', bar: 'baz' })).toBe( | ||
false | ||
); | ||
expect(isEqualLocals({ foo: 'bar', bar: 'baz' }, { foo: 'bar' })).toBe( | ||
false | ||
); | ||
|
||
// Should never happen, but let's test it | ||
expect(isEqualLocals({ foo: 'bar' }, { foo: true })).toBe(false); | ||
expect(isEqualLocals({ foo: true }, { foo: 'bar' })).toBe(false); | ||
// eslint-disable-next-line no-undefined | ||
expect(isEqualLocals({ foo: 'bar' }, { foo: undefined })).toBe(false); | ||
expect(isEqualLocals({ foo: undefined }, { foo: 'bar' })).toBe(false); | ||
expect(isEqualLocals({ foo: { foo: 'bar' } }, { foo: 'bar' })).toBe(false); | ||
}); | ||
}); |