Skip to content

Doesn’t work with turbolinks #26

@temochka

Description

@temochka

Currently, when imported, the JS client adds "_tt" CSS class to the document body and fires a relevant event. The Test Track Chrome extension looks for this class name when determining whether to be active for the current page. This approach doesn’t play well with Turbolinks, which entirely replaces the document body on every page transition, but keeps existing scripts in <head> loaded. To integrate with libraries that store some state in page DOM, Turbolinks can fire a hook on every URL change, which would be the perfect place to re-initialize TestTrack:

# turbolinks-classic

$(document).on('ready page:load', function(event) {
  initTestTrack();
});

# turbolinks

document.addEventListener("turbolinks:load", function() {
  initTestTrack();
})

Unfortunately, the existing TestTrack.initialize() doesn’t redo the DOM modification if the class is missing. Is there a good reason why? The related question is whether testtrack should be doing any DOM modification on load at all or that part should be deferred until initialization?

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