Skip to content
This repository has been archived by the owner on Oct 8, 2024. It is now read-only.

Commit

Permalink
Makes Dropdown SSR compatible #66
Browse files Browse the repository at this point in the history
  • Loading branch information
zenorocha committed Feb 20, 2018
1 parent 5887712 commit 78a1c6c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/marble-dropdown/src/Dropdown.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {core, object} from 'metal';
import {core, object, isServerSide} from 'metal';
import dom from 'metal-dom';
import {Align} from 'metal-position';
import Component from 'metal-component';
Expand All @@ -16,6 +16,11 @@ class Dropdown extends Component {
*/
attached() {
super.attached();

if (isServerSide()) {
return;
}

this.eventHandler_.add(
dom.on(document, 'click', this.handleDocClick_.bind(this))
);
Expand Down
13 changes: 13 additions & 0 deletions packages/marble-dropdown/test/Dropdown.node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* @jest-environment node
*/

import Component from 'metal-component';
import Dropdown from '../src/Dropdown';

describe('Dropdown.node', () => {
it('should not fail on the server side', () => {
const dropdown = Component.renderToString(Dropdown);
expect(dropdown).not.toBeNull();
});
});

0 comments on commit 78a1c6c

Please sign in to comment.