Add Custom Placeholder Handling when rendering the card fields

This commit is contained in:
Narek Zakarian 2024-09-27 19:11:35 +04:00
parent 2d425cc943
commit 8b6cb86dbb
No known key found for this signature in database
GPG key ID: 07AFD7E7A9C164A7

View file

@ -8,11 +8,17 @@ function renderField( cardField, inputField ) {
// Insert the PayPal card field after the original input field.
const styles = cardFieldStyles( inputField );
cardField( { style: { input: styles } } ).render( inputField.parentNode );
const fieldOptions = {style: { input: styles },};
// Hide the original input field.
hide( inputField, true );
inputField.hidden = true;
if ( inputField.getAttribute( 'placeholder' ) ) {
fieldOptions.placeholder = inputField.getAttribute( 'placeholder' );
}
cardField( fieldOptions ).render( inputField.parentNode );
// Hide the original input field.
hide( inputField, true );
inputField.hidden = true;
}
export function renderFields( cardFields ) {