浏览代码

Fixed webpack 4 builds breaking due to nullish coalescing operator (#3679)

* Fixed webpack 4 builds breaking due to nullish coalescing operator

* Replaced another usage of nullish coalescing with explicit typechecks in order to fix webpack 4 builds

---------

Co-authored-by: Martin Schön <martin.schoen@spiegel.de>
mgschoen 1 年之前
父节点
当前提交
ba08ec4201
共有 2 个文件被更改,包括 4 次插入2 次删除
  1. 1 1
      packages/alpinejs/src/directives/x-model.js
  2. 3 1
      packages/mask/src/index.js

+ 1 - 1
packages/alpinejs/src/directives/x-model.js

@@ -134,7 +134,7 @@ function getInputValue(el, modifiers, event, currentValue) {
         // Safari autofill triggers event as CustomEvent and assigns value to target
         // Safari autofill triggers event as CustomEvent and assigns value to target
         // so we return event.target.value instead of event.detail
         // so we return event.target.value instead of event.detail
         if (event instanceof CustomEvent && event.detail !== undefined)
         if (event instanceof CustomEvent && event.detail !== undefined)
-            return event.detail ?? event.target.value
+            return event.detail !== null && event.detail !== undefined ? event.detail : event.target.value
         else if (el.type === 'checkbox') {
         else if (el.type === 'checkbox') {
             // If the data we are binding to is an array, toggle its value inside the array.
             // If the data we are binding to is an array, toggle its value inside the array.
             if (Array.isArray(currentValue)) {
             if (Array.isArray(currentValue)) {

+ 3 - 1
packages/mask/src/index.js

@@ -174,7 +174,9 @@ export function formatMoney(input, delimiter = '.', thousands, precision = 2) {
     if (input === '-') return '-'
     if (input === '-') return '-'
     if (/^\D+$/.test(input)) return '9'
     if (/^\D+$/.test(input)) return '9'
 
 
-    thousands = thousands ?? (delimiter === "," ? "." : ",")
+    if (thousands === null || thousands === undefined) {
+        thousands = delimiter === "," ? "." : ","
+    }
 
 
     let addThousands = (input, thousands) => {
     let addThousands = (input, thousands) => {
         let output = ''
         let output = ''