JSFiddle - React, Tailwind, and code Playground

HTML

<html>
    <body>
        Hello, World
    </body>
</html>

JavaScript

$(function() {

    // nothing on page matches the selector, so I'd expect the
    // inner function to not be called.
    $("div.marker").replaceWith(function() {
        alert('Seems like this should never be called since there are no matching elements.');

        if(this == window) {
            alert('I was not expecting this == window.');
        }
        
        // this line blows up.
        $(this).attr('data-some-attr-i-want');
    });

});