Skip to content

Improvement needed to initialization #4

@ThreeDfish

Description

@ThreeDfish

I would recommend the following changes:

define the variable in rebuildMasks() using let

function rebuildMasks() {
	let maskFields = _getMaskFields();
	let masks = _getMasks(maskFields);
	_setupMaskEvents(maskFields, masks);
}

remove the current initialization code and put the following at the bottom of the script:

// Initialize when document is loaded
document.addEventListener("DOMContentLoaded", rebuildMasks);

There is no reason for maskFields and masks to be global variables, and the initialization code was just a duplicate of the rebuildMasks() function, and initializing the masks should not happen before the entire document is loaded.

If you want, I can fork and make those changes and put it into a pull request...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions