mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-30 05:00:51 +08:00
Extract repeat logic into new helper method
This commit is contained in:
parent
36522f685c
commit
fc4d2baa67
1 changed files with 14 additions and 0 deletions
|
@ -1,6 +1,20 @@
|
|||
import { cardFieldStyles } from './CardFieldsHelper';
|
||||
import { hide } from '../../../ppcp-button/resources/js/modules/Helper/Hiding';
|
||||
|
||||
function renderField( cardField, inputField ) {
|
||||
if ( ! inputField || inputField.hidden || ! cardField ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Insert the PayPal card field after the original input field.
|
||||
const styles = cardFieldStyles( inputField );
|
||||
cardField( { style: { input: styles } } ).render( inputField.parentNode );
|
||||
|
||||
// Hide the original input field.
|
||||
hide( inputField, true );
|
||||
inputField.hidden = true;
|
||||
}
|
||||
|
||||
export function renderFields( cardFields ) {
|
||||
const nameField = document.getElementById(
|
||||
'ppcp-credit-card-gateway-card-name'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue