Skip to content

Commit dd0b13d

Browse files
committed
Fix model
1 parent ca216d0 commit dd0b13d

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

@types/directive/model/model.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export function ngModelDirective(): {
55
priority: number;
66
compile: (element: Element) => {
77
pre: (scope: any, _element: any, attr: any, ctrls: any) => void;
8-
post: (scope: any, element: any, _attr: any, ctrls: any) => void;
8+
post: (scope: any, elementPost: any, _attr: any, ctrls: any) => void;
99
};
1010
};
1111
export const ngModelMinErr: (arg0: string, ...arg1: any[]) => Error;

src/directive/model/model.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,12 @@ export class NgModelController {
364364
* @returns {boolean} True if `value` is "empty".
365365
*/
366366
$isEmpty(value) {
367-
return isUndefined(value) || value === "" || value === null || isNaN(value);
367+
return (
368+
isUndefined(value) ||
369+
value === "" ||
370+
value === null ||
371+
Number.isNaN(value)
372+
);
368373
}
369374

370375
$$updateEmptyClasses(value) {
@@ -825,7 +830,8 @@ export class NgModelController {
825830

826831
function writeToModelIfNeeded() {
827832
// intentional loose equality
828-
if (that.$modelValue !== prevModelValue) {
833+
// eslint-disable-next-line eqeqeq
834+
if (that.$modelValue != prevModelValue) {
829835
that.$$writeModelToScope();
830836
}
831837
}
@@ -1210,7 +1216,7 @@ export function ngModelDirective() {
12101216
deregisterWatch();
12111217
});
12121218
},
1213-
post: (scope, element, _attr, ctrls) => {
1219+
post: (scope, elementPost, _attr, ctrls) => {
12141220
const modelCtrl = ctrls[0];
12151221

12161222
modelCtrl.$$setUpdateOnEvents();
@@ -1219,13 +1225,13 @@ export function ngModelDirective() {
12191225
modelCtrl.$setTouched();
12201226
}
12211227

1222-
element.addEventListener("blur", () => {
1228+
elementPost.addEventListener("blur", () => {
12231229
if (modelCtrl.$touched) return;
12241230
setTouched();
12251231
});
12261232

12271233
modelCtrl.$viewChangeListeners.push(() =>
1228-
scope.$eval(element.dataset.change),
1234+
scope.$eval(elementPost.dataset.change),
12291235
);
12301236
},
12311237
};

0 commit comments

Comments
 (0)