-
Notifications
You must be signed in to change notification settings - Fork 14
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
pass container element to iframe stamper #183
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
also, i think the test we have in |
packages/iframe-stamper/src/index.ts
Outdated
); | ||
} | ||
this.container = container; | ||
this.container = config.iframeContainer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the check above (on line 64) needs to be updated, from document.getElementById(config.iframeElementId)
to this.container.querySelector(`#${config.iframeElement}`)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀 👀 Fixed, thanks!
packages/iframe-stamper/src/index.ts
Outdated
); | ||
} | ||
this.container = container; | ||
this.container = config.iframeContainer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Separately: do we need to check for config.iframeContainer !== undefined
? Or is it already implicit if the type is HTMLElement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! Looked into this and the document.getElementById
and document.querySelector
both return HTMLElement | null
when the element's not found. However, they can return undefined
when they're accessed before the element is created. In short, yep I added this check. Thanks!
@@ -5,42 +5,19 @@ import { IframeStamper } from "@turnkey/iframe-stamper"; | |||
import * as React from "react"; | |||
import { useEffect, useState } from "react"; | |||
import axios from "axios"; | |||
import { Export } from "@/components/Export"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clean!! ❤️
if (!iframeStamper) { | ||
const iframeContainer = document.getElementById(TurnkeyIframeContainerId); | ||
if (!iframeContainer) { | ||
console.error(`Cannot create iframe stamper: no container with ID ${TurnkeyIframeContainerId} exists`); | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still necessary given the component is in control of creating / inserting the container into the DOM?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this check here since I made the change above allowing for iframeContainer
to be passed as null/undefined and the check is done in the iframe stamper's constructor now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
…pdate auth, recovery, export examples. clean up export example
e42d182
to
a71d6ed
Compare
Summary & Motivation
turnkey/iframe-stamper
package major version.How I Tested These Changes
Did you add a changeset?
If updating one of our packages, you'll likely need to add a changeset to your PR. To do so, run
pnpm changeset
.pnpm changeset
will generate a file where you should write a human friendly message about the changes. Note how this (example) includes the package name (should be auto added by the command) along with the type of semver change (major.minor.patch) (which you should set).These changes will be used at release time to determine what packages to publish and how to bump their version. For more context see this comment.