avm1: Empty text field does not initialize variable binding

If a text field with a variable binding is placed on the stage,
usually the variable is initialized with the initial text. However,
if the text field is empty, the variable remains undefined.

Fixes #777.
This commit is contained in:
Mike Welsh 2020-07-02 00:05:21 -07:00
parent b05da5ef0f
commit dd32acd8fc
1 changed files with 11 additions and 3 deletions

View File

@ -736,9 +736,17 @@ impl<'gc> EditText<'gc> {
context,
);
} else {
// Otherwise, we initialize the proprty with the text field's text.
let _ =
object.set(property, self.text().into(), activation, context);
// Otherwise, we initialize the proprty with the text field's text, if it's non-empty.
// Note that HTML text fields are often initialized with an empty <p> tag, which is not considered empty.
let text = self.text();
if !text.is_empty() {
let _ = object.set(
property,
self.text().into(),
activation,
context,
);
}
}
}