From dd32acd8fc8e30815613c432dae98f8687dfcaa2 Mon Sep 17 00:00:00 2001 From: Mike Welsh Date: Thu, 2 Jul 2020 00:05:21 -0700 Subject: [PATCH] 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. --- core/src/display_object/edit_text.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/core/src/display_object/edit_text.rs b/core/src/display_object/edit_text.rs index 66068000d..2b1e4ffd2 100644 --- a/core/src/display_object/edit_text.rs +++ b/core/src/display_object/edit_text.rs @@ -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

tag, which is not considered empty. + let text = self.text(); + if !text.is_empty() { + let _ = object.set( + property, + self.text().into(), + activation, + context, + ); + } } }