private staticDictionary: StaticDictionary;
private feedbacker: zxcvbn.Feedback;
- private readonly wrapper = document.createElement("div");
+ private wrapper: HTMLDivElement;
private readonly score = document.createElement("span");
private readonly verdictResult = document.createElement("input");
this.feedbacker = initializeFeedbacker(zxcvbn.Feedback);
- this.wrapper.className = "inputAddon inputAddonPasswordStrength";
- this.input.parentNode!.insertBefore(this.wrapper, this.input);
- this.wrapper.appendChild(this.input);
+ const wrapper: HTMLDivElement | null = this.input.closest(".inputAddon");
+ if (wrapper === null) {
+ throw new Error("Expected a parent with `.inputAddon`.");
+ }
+
+ this.wrapper = wrapper;
+ this.wrapper.classList.add("inputAddonPasswordStrength");
const rating = document.createElement("div");
rating.className = "passwordStrengthRating";
class PasswordStrength {
constructor(input, options) {
this.input = input;
- this.wrapper = document.createElement("div");
this.score = document.createElement("span");
this.verdictResult = document.createElement("input");
void new Promise((resolve_1, reject_1) => { require(["zxcvbn"], resolve_1, reject_1); }).then(tslib_1.__importStar).then(({ default: zxcvbn }) => {
this.staticDictionary = options.staticDictionary;
}
this.feedbacker = initializeFeedbacker(zxcvbn.Feedback);
- this.wrapper.className = "inputAddon inputAddonPasswordStrength";
- this.input.parentNode.insertBefore(this.wrapper, this.input);
- this.wrapper.appendChild(this.input);
+ const wrapper = this.input.closest(".inputAddon");
+ if (wrapper === null) {
+ throw new Error("Expected a parent with `.inputAddon`.");
+ }
+ this.wrapper = wrapper;
+ this.wrapper.classList.add("inputAddonPasswordStrength");
const rating = document.createElement("div");
rating.className = "passwordStrengthRating";
const ratingLabel = document.createElement("small");