src/core/dom/form.js
/**
 * Checks if a form field is in its default state.
 * @param {HTMLInputElement|HTMLSelectElement} field
 * @return {boolean}
 */
Checks if a form field is in its default state.
Checks if a form field is in its default state .
function isFieldDefault(field) {
  const fieldAsSelect =  (field);
  const fieldAsInput =  (field);
  switch (field.type) {
    case 'select-multiple':
    case 'select-one':
      return toArray(fieldAsSelect.options).every(
        ({defaultSelected, selected}) => selected === defaultSelected
      );
    case 'checkbox':
    case 'radio':
      const {checked, defaultChecked} = fieldAsInput;
      return checked === defaultChecked;
    default:
      const {defaultValue, value} = fieldAsInput;
      return value === defaultValue;
  }
}
function isFieldDefault ( field ) { const fieldAsSelect = ( field ) ; const fieldAsInput = ( field ) ; switch ( field . type ) { case 'select-multiple' : case 'select-one' : return toArray ( fieldAsSelect . options ) . every ( ( { defaultSelected , selected } ) => selected === defaultSelected ) ; case 'checkbox' : case 'radio' : const { checked , defaultChecked } = fieldAsInput ; return checked === defaultChecked ; default : const { defaultValue , value } = fieldAsInput ; return value === defaultValue ; } }
Checks if a form field is in its default state.
Checks if a form field is in its default state .
/** @type {HTMLSelectElement} */ /** @type {HTMLInputElement} */