Skip to content

Commit

Permalink
Don't use display:none to hide token form iframe
Browse files Browse the repository at this point in the history
  • Loading branch information
golive committed Jun 10, 2024
1 parent 9d32e49 commit 72418e0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/paymentForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,17 @@ const paymentForm = ({
name: 'mufasa-iframe',
src: url,
});
const tokenFormStyles = !hidden ? {} : {
position: 'absolute',
height: '0px',
left: '-999px',
overflow: 'hidden',
opacity: '0',
};
setElementStyles(mufasaIframe, {
...baseStyles,
...styles,
display: hidden ? 'none' : 'block'
...tokenFormStyles,
});
if(className) {
mufasaIframe.className = className;
Expand Down
8 changes: 7 additions & 1 deletion src/tests/sequraPCI.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ describe('SequraPCI', () => {
test('mounts the iframe in the DOM, hidden', () => {
paymentForm = SequraPCI.paymentForm({ url: emptyUrl }).mount('my-container', { hidden: true });
const mufasaIframe = document.querySelector('iframe');
expect(mufasaIframe.style["display"]).toEqual("none");
expect(mufasaIframe).toHaveStyle({
position: 'absolute',
height: '0px',
left: '-999px',
overflow: 'hidden',
opacity: '0',
});
});

test('it uses custom styles', () => {
Expand Down

0 comments on commit 72418e0

Please sign in to comment.