Skip to content
This repository was archived by the owner on Sep 11, 2022. It is now read-only.

Conversation

@bmalets
Copy link

@bmalets bmalets commented Jan 9, 2019

There is closed an issue related to bad ID of sticky wrapper element: id="undefined-sticky-wrapper"

Current line from master branch defines wrapper ID:

var wrapperId = stickyId ? stickyId + '-' + defaults.wrapperClassName : defaults.wrapperClassName;

It means if your sticky element has id="dummy", wrapper will have id="dummy-sticky-wrapper".
If your sticky element does not have an ID - wrapper will have id="undefined-sticky-wrapper".

There is a problem when we have a few sticky elements on page without id (sidebar and header etc.)
it's not good to have two wrappers with that same id "undefined-sticky-wrapper"

How about to change this line with:

var wrapperIdSuffix = stickyId ? stickyId : new Date().valueOf();
var wrapperId = defaults.wrapperClassName + '-' + wrapperIdSuffix;

In this case wrapper id with will be more readable and it will be always unique on page (because timestamp is unique).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Will only work as intended on elements with an ID

1 participant