Skip to content

Original style values used for restoration onDestroy are overridden onCreate #103

@joshua-econify

Description

@joshua-econify

Writing some tests to familiarize with ad.js (+ bonus increase coverage) and came across:

    this.originalStyle = container.style;

    container.style.position = 'sticky';
    container.style.top = `${stickyOffset}px`;

https://github.com/Econify/ad.js/blob/master/src/plugins/Sticky.ts#L34

Understanding is original style is a reference to container.style so the next line that sets the value of container.style overwrites the original value to be preserved in this.originalStyle (used for restoration in .onDestroy -> .cleanUp). As is this means position and top if set are never restored to their original values onDestroy -> cleanUp.

Fix and test coverage here: https://github.com/Econify/ad.js/tree/bugfix/restore-original-container-style-on-destroy

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions