-
Notifications
You must be signed in to change notification settings - Fork 75
feat: adds prop update listening to modal browser zoid polyfill #1161
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
ecf1a92
adds browser new prop event listener
danzhaaspaypal 71f28c8
adds prop update listening to modal browser zoid polyfill
danzhaaspaypal 701bdd8
fixes postMessage and refactors a bit
danzhaaspaypal a0c0b0b
removes comments
danzhaaspaypal 3f5908f
adds trusted origin to event ack postMessage
danzhaaspaypal 7da92bb
corrects offerTypes param name
danzhaaspaypal 8f938f5
addresses comments
danzhaaspaypal 172e52e
Merge branch 'develop' of https://github.com/paypal/paypal-messaging-…
danzhaaspaypal 7cc1fdc
improves function names
danzhaaspaypal d7de8c5
Merge branch 'develop' of https://github.com/paypal/paypal-messaging-…
danzhaaspaypal 50fb154
feat: sends modal event data to modal wrapper for use in hooks (#1170)
danzhaaspaypal 7acc1a6
Merge branch 'develop' into feature/DTCRCMERC-3611-modal-lander-v6
yeul File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |||||
| import arrayFrom from 'core-js-pure/stable/array/from'; | ||||||
| import { isIosWebview, isAndroidWebview } from '@krakenjs/belter/src'; | ||||||
| import { request, memoize, ppDebug } from '../../../../utils'; | ||||||
| import validate from '../../../../library/zoid/message/validation'; | ||||||
|
|
||||||
| export const getContent = memoize( | ||||||
| ({ | ||||||
|
|
@@ -112,3 +113,59 @@ | |||||
| } | ||||||
| return currentDate.toLocaleDateString('en-GB', options); | ||||||
| } | ||||||
|
|
||||||
| export function createUUID() { | ||||||
| // crypto.randomUUID() is only available in HTTPS secure environments and modern browsers | ||||||
| if (typeof crypto !== 'undefined' && crypto && crypto.randomUUID instanceof Function) { | ||||||
| return crypto.randomUUID(); | ||||||
| } | ||||||
|
|
||||||
| const validChars = '0123456789abcdefghijklmnopqrstuvwxyz'; | ||||||
| const stringLength = 32; | ||||||
| let randomId = ''; | ||||||
| for (let index = 0; index < stringLength; index++) { | ||||||
| const randomIndex = Math.floor(Math.random() * validChars.length); | ||||||
| randomId += validChars.charAt(randomIndex); | ||||||
| } | ||||||
| return randomId; | ||||||
| } | ||||||
|
|
||||||
| export function validateProps(updatedProps) { | ||||||
| const validatedProps = {}; | ||||||
| Object.entries(updatedProps).forEach(entry => { | ||||||
| const [k, v] = entry; | ||||||
| if (k === 'offerType') { | ||||||
| validatedProps.offer = validate.offer({ props: { offer: v } }); | ||||||
| } else { | ||||||
| validatedProps[k] = validate[k]({ props: { [k]: v } }); | ||||||
| } | ||||||
Seavenly marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| }); | ||||||
| return validatedProps; | ||||||
| } | ||||||
|
|
||||||
| export function sendEventAck(eventId) { | ||||||
| // skip this step if running in test env because jest's target windows don't support postMessage | ||||||
| if (window.process?.env?.NODE_ENV === 'test') { | ||||||
|
||||||
| if (window.process?.env?.NODE_ENV === 'test') { | |
| if (process.env.NODE_ENV === 'test') { |
Seavenly marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Seavenly marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Fixed
Show fixed
Hide fixed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.