diff --git a/packages/marble-datatable/src/Datatable.js b/packages/marble-datatable/src/Datatable.js index e1cbbb3..9b79f6a 100644 --- a/packages/marble-datatable/src/Datatable.js +++ b/packages/marble-datatable/src/Datatable.js @@ -1,4 +1,4 @@ -import core from 'metal'; +import {core, isServerSide} from 'metal'; import dom from 'metal-dom'; import templates from './Datatable.soy.js'; import Component from 'metal-component'; @@ -7,6 +7,19 @@ import Soy from 'metal-soy'; import UA from 'metal-useragent'; class Datatable extends Component { + /** + * @inheritDoc + */ + attached() { + if (isServerSide()) { + return; + } + + this.keyboardFocusManager_ = new KeyboardFocusManager(this, 'td,th') + .setFocusHandler(this.handleNextFocus_.bind(this)) + .start(); + } + /** * Visits array items and asserts that it only contains one literal type. * @param {array} value @@ -38,15 +51,6 @@ class Datatable extends Component { } } - /** - * @inheritDoc - */ - attached() { - this.keyboardFocusManager_ = new KeyboardFocusManager(this, 'td,th') - .setFocusHandler(this.handleNextFocus_.bind(this)) - .start(); - } - /** * Builds a ref with for the given row and column positions. * @param {string} prefix diff --git a/packages/marble-datatable/test/Datatable.node.js b/packages/marble-datatable/test/Datatable.node.js new file mode 100644 index 0000000..3c06782 --- /dev/null +++ b/packages/marble-datatable/test/Datatable.node.js @@ -0,0 +1,13 @@ +/** + * @jest-environment node + */ + +import Component from 'metal-component'; +import Datatable from '../src/Datatable'; + +describe('Datatable.node', () => { + it('should not fail on the server side', () => { + const datatable = Component.renderToString(Datatable); + expect(datatable).not.toBeNull(); + }); +});