Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

"this" is undefined in header.js in strict mode #293

Closed
chtheis opened this issue Aug 6, 2020 · 4 comments
Closed

"this" is undefined in header.js in strict mode #293

chtheis opened this issue Aug 6, 2020 · 4 comments

Comments

@chtheis
Copy link

chtheis commented Aug 6, 2020

I'm trying to instrument an ES6 module (note I speak of client side JS, not Node.js).
It looks like the initialization of an instrumented file throws an Exception in header.js line 38, because "this" is undefined here. Unlike plain JS modules seem to be very picky about this ...
What is "this" supposed to be in this context?

In a fork I deleted "this." from header.js and with the new jar my test just ran fine.

It may be possible if you add "use strict"; to a file, but I haven't tried that.

@chtheis
Copy link
Author

chtheis commented Aug 8, 2020

I created PR #294 with some more changes in the .js files but the integration tests fail. I could fix a few failures which were caused by my changes but not all. Currently it fails at "inMemory.js" but I can't find that file.
Any help is appreciated.

@chtheis
Copy link
Author

chtheis commented Aug 8, 2020

Finally I managed to run the integration tests with success ...

It might be better to declare _$jscoverage in header.js instead of touching a couple of places where it is first assigned a value but I don't understand the code good enough to make that decision.

@tntim96 tntim96 self-assigned this Jun 12, 2022
@tntim96
Copy link
Owner

tntim96 commented Oct 30, 2022

Hi @chtheis , sorry for not following up on this sooner. I believe this has been fixed in #311 , commit 0eca598. Can you confirm?

@tntim96
Copy link
Owner

tntim96 commented Oct 30, 2022

I've released it in the 2.0.16 SNAPSHOT if you'd like to test.

<repositories>
    <repository>
        <id>sonatype-nexus-snapshots</id>
        <name>Sonatype Nexus Snapshots</name>
        <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>

Or build the latest JAR yourself or download from here.

Let me know if that fixes your issue and I'll build a release.

@tntim96 tntim96 changed the title "this" is undefined in header.js "this" is undefined in header.js in strict mode Nov 2, 2022
@tntim96 tntim96 closed this as completed Nov 2, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants