Closed HRMsimon closed 4 years ago
Our workaround:
<?hh // strict
/**
* A wrapper for :input
*
* :input doesn't support step="any", so we force it.
* @see https://github.com/facebook/xhp-lib/issues/162
*/
class :ee:input extends :x:element {
use XHPHelpers;
attribute mixed step, :input;
category %flow, %phrase, %interactive;
public function render(): :input {
$input = <input />;
if ($this->isAttributeSet('step')) {
$value = $this->:step;
if ($value !== 'any' && !is_float($value)) {
try {
$value = XHPAttributeCoercion::CoerceToFloat($this, 'step', $value);
} catch (XHPInvalidAttributeException $e) {
throw new XHPInvalidAttributeException(
$this,
'float or "any"',
'step',
$value,
);
}
}
$input->forceAttribute('step', $value);
$this->removeAttribute('step');
}
return $input;
}
}
For my future reference: 'any' !== unspecified; unspecified uses defaults rather than allowing anything.
The value for the
step
attribute on an input can be:XHP only allows a float.