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

Commit

Permalink
Makes Autocomplete SSR compatible #66
Browse files Browse the repository at this point in the history
  • Loading branch information
zenorocha committed Feb 20, 2018
1 parent 82b02f7 commit 5887712
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/marble-autocomplete/src/Autocomplete.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import core from 'metal';
import {core, isServerSide} from 'metal';
import debounce from 'metal-debounce';
import dom from 'metal-dom';
import {CancellablePromise as Promise} from 'metal-promise';
Expand All @@ -23,6 +23,11 @@ class Autocomplete extends AutocompleteBase {
*/
attached() {
super.attached();

if (isServerSide()) {
return;
}

this.setAriaAttributes_();
this.eventHandler_.add(
dom.on(this.inputElement, 'focus', this.handleInputFocus_.bind(this))
Expand Down
13 changes: 13 additions & 0 deletions packages/marble-autocomplete/test/Autocomplete.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 Autocomplete from '../src/Autocomplete';

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

0 comments on commit 5887712

Please sign in to comment.