Closed btxtiger closed 6 years ago
Hi, I have two questions:
1) What is the barColorsChecked
boolean used for? Should it prevent the colors to be changed more than once? But what if the first try fails for whatever reason?
2) src/passwordStrengthBar.component.ts:59
I'm not sure if here isn't created a reference.
this.colors = this.barColors;
If we write it this way:
var k = [1,2,3,4,5];
var b = [3,3,3,3,3];
var b = k;
b[0] = 99
// Output b: [99, 2, 3, 4, 5]
// Output k: [99, 2, 3, 4, 5]
I'm still not that familiar with ES6 classes, so it might be possible assigning this
way this.colors = this.barColors;
might be correct.
If it is a reference, this.barColors
is changeable on the flow if this.myColors
is updated. That would mean there isn't a secure working fallback if myColors becomes undefined
for whatever reason. That's why I used this.colors = this.barColors.slice();
here.
I originally assumed that the check only needed to be done once. It doesn't seem like a common use case, but there's nothing preventing the client from dynamically changing the colors. I've updated the logic to check on every change and revert back to the default when validation fails.
Looks good for me. I've nothing to add.
Thanks @btxtiger! Please take a look at the changes I made on the btxtiger-master branch. If you don't have further comments I will merge and push the new version to npm.