When content obtained through $element('id') is assigned to a member variable, a stack overflow (RangeError: Maximum call stack size exceeded) may occur and the program will crash. If member variable references exist for a DOM, and a member variable changes, a stack overflow will also occur. The sample code is as follows:
The reason is that value assignment will lead to massive data changes. As a result, an internal abnormal loop occurs, causing a stack overflow.
Solution
To prevent a stack overflow, you can assign data obtained through $element('id') to a local or global variable rather than a member variable. The sample code is as follows:
Top comments (0)