Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Don't wrap Promise constructor in older browsers #22

Merged
merged 2 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# changelog

## 0.1.11

* Fix wrapping of Promise constructor, which lead to issues in Chrome <= 45 (released September 2015) and Firefox <= 40.

## 0.1.10

* Fix use of ES features in non-compat build, which caused Safari 11.1 and 12.1 to fail to load the SDK.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@friendlycaptcha/sdk",
"version": "0.1.10",
"version": "0.1.11",
"description": "In-browser SDK for Friendly Captcha v2 (currently in preview only)",
"main": "dist/sdk.js",
"type": "module",
Expand Down
6 changes: 5 additions & 1 deletion sdktest/render/script.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ import (
"github.com/evanw/esbuild/pkg/api"
)

func (r *TestCaseHandler) loadAndBuildScript(templates *template.Template, path string, renderData TestCaseRenderData) ([]byte, error) {
func (r *TestCaseHandler) loadAndBuildScript(
templates *template.Template,
path string,
renderData TestCaseRenderData,
) ([]byte, error) {
scriptEntry, err := executeTemplateIfExists(templates, path, renderData)
if err != nil {
return nil, err
Expand Down
8 changes: 7 additions & 1 deletion src/signals/collectStacktrace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export const takeRecords = (function () {

// We save some bundle size by using these constants.
const p = "prototype";
const c = "constructor";

// Safari 10.1 (and 10.3 on iOS) and earlier does not have `EventTarget` defined.
const dispatchEvent = w.EventTarget ? w.EventTarget[p].dispatchEvent : {};
Expand All @@ -99,13 +100,18 @@ export const takeRecords = (function () {
["Document." + p + ".querySelectorAll", w.Document[p], "querySelectorAll"],
["Document." + p + ".createElement", w.Document[p], "createElement"],
["EventTarget." + p + ".dispatchEvent", dispatchEvent, "dispatchEvent"],
["Promise." + p + "e.constructor", w.Promise[p], "constructor"],
["Promise." + p + "." + c, w.Promise[p], c],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is leaving out the e intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that was a small typo bug :)

];

patches.forEach(function ([name, target, prop]) {
const descriptor = Object.getOwnPropertyDescriptor(target, prop);
const hasGetterOrSetter = descriptor && (descriptor.get || descriptor.set);

// We skip the patching of the constructor property if `Symbol.species` is not supported.
if (prop === c && !(w.Symbol && w.Symbol.species)) {
return;
}

if (!descriptor) {
return;
} else if (hasGetterOrSetter) {
Expand Down