avm2: Handle setting tabIndex to -1

Despite throwing an error that `tabIndex` cannot be negative,
the value of -1 is allowed, and it means that `tabIndex` is unset.
This commit is contained in:
Kamil Jarosz 2024-04-30 13:42:08 +02:00 committed by Nathan Adams
parent f40cb6435f
commit 8ee514e62f
1 changed files with 3 additions and 1 deletions

View File

@ -168,7 +168,9 @@ pub fn set_tab_index<'gc>(
) -> Result<Value<'gc>, Error<'gc>> {
if let Some(obj) = this.as_display_object().and_then(|o| o.as_interactive()) {
let value = args.get_i32(activation, 0)?;
if value < 0 {
// Despite throwing an error that tabIndex cannot be negative,
// the value of -1 is allowed, and it means that tabIndex is unset.
if value < -1 {
return Err(make_error_2027(activation, value));
}
obj.set_tab_index(&mut activation.context, Some(value));