Skip to content
This repository has been archived by the owner on Apr 18, 2018. It is now read-only.

Commit

Permalink
Makes Scrollspy SSR compatible #5
Browse files Browse the repository at this point in the history
  • Loading branch information
zenorocha committed Feb 17, 2018
1 parent db1dd10 commit 7831cb2
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/Scrollspy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import core from 'metal';
import {core, isServerSide} from 'metal';
import dom from 'metal-dom';
import Position from 'metal-position';
import State from 'metal-state';
Expand All @@ -15,6 +15,10 @@ class Scrollspy extends State {
constructor(opt_config) {
super(opt_config);

if (isServerSide()) {
return;
}

/**
* Holds the regions cache.
* @type {!Array}
Expand All @@ -37,6 +41,10 @@ class Scrollspy extends State {
* @inheritDoc
*/
disposeInternal() {
if (isServerSide()) {
return;
}

this.deactivateAll();
this.scrollHandle_.dispose();
super.disposeInternal();
Expand Down Expand Up @@ -255,7 +263,13 @@ Scrollspy.STATE = {
*/
scrollElement: {
setter: dom.toElement,
value: document
valueFn: function() {
if (isServerSide()) {
return;
}

return document;
}
},

/**
Expand Down

0 comments on commit 7831cb2

Please sign in to comment.