فهرست منبع

added a check to see if event.detail existed in model.js

also modified the examples to add the CustomEvent polyfill
Keyur Shah 5 سال پیش
والد
کامیت
b040b46192
7فایلهای تغییر یافته به همراه131 افزوده شده و 2 حذف شده
  1. 0 0
      dist/alpine-ie11.js
  2. 0 0
      dist/alpine-ie11.js.map
  3. 0 0
      dist/alpine.js
  4. 0 0
      dist/alpine.js.map
  5. 12 1
      examples/index_ie11.html
  6. 118 0
      examples/index_ie11_event.html
  7. 1 1
      src/directives/model.js

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
dist/alpine-ie11.js


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
dist/alpine-ie11.js.map


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
dist/alpine.js


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
dist/alpine.js.map


+ 12 - 1
examples/index_ie11.html

@@ -19,7 +19,7 @@
     </style>
 
     <script
-        src="https://polyfill.io/v3/polyfill.min.js?features=MutationObserver%2CArray.from%2CArray.prototype.forEach%2CMap%2CSet%2CArray.prototype.includes%2CString.prototype.includes%2CPromise%2CNodeList.prototype.forEach%2CObject.values%2CReflect%2CReflect.set%2CString.prototype.startsWith%2CArray.prototype.find%2CArray.prototype.findIndex%2CElement.prototype.closest%2CElement.prototype.remove">
+        src="https://polyfill.io/v3/polyfill.min.js?features=MutationObserver%2CArray.from%2CArray.prototype.forEach%2CMap%2CSet%2CArray.prototype.includes%2CString.prototype.includes%2CPromise%2CNodeList.prototype.forEach%2CObject.values%2CReflect%2CReflect.set%2CString.prototype.startsWith%2CArray.prototype.find%2CArray.prototype.findIndex%2CElement.prototype.closest%2CElement.prototype.remove%2CCustomEvent">
     </script>
 
 
@@ -342,6 +342,17 @@
                     </script>
                 </td>
             </tr>
+            
+            <tr>
+                <td>Dispatch</td>
+                <td>
+                    <div x-data="{ foo: 'bar' }" x-on:custom-event="foo = $event.detail.newValue">
+                        <span x-text="foo"></span>
+
+                        <button x-on:click="$dispatch('custom-event', {newValue: 'baz'})">Turn 'bar' to 'baz'</button>
+                    </div>
+                </td>
+            </tr>
 
             <tr>
                 <td>Cloak</td>

+ 118 - 0
examples/index_ie11_event.html

@@ -0,0 +1,118 @@
+<!doctype html>
+<html>
+
+<head>
+    <meta http-equiv="X-UA-Compatible" content="IE=edge;" />
+
+    <style>
+        .hidden {
+            display: none;
+        }
+
+        [x-cloak] {
+            display: none;
+        }
+
+        .opacity-0 {
+            opacity: 0;
+        }
+
+        .opacity-100 {
+            opacity: 1;
+        }
+
+        .transition-slow {
+            transition-duration: 300ms;
+        }
+
+        .transition-medium {
+            transition-duration: 200ms;
+        }
+
+        .transition-faster {
+            transition-duration: 100ms;
+        }
+
+        .scale-90 {
+            transform: scale(0.9);
+        }
+
+        .scale-100 {
+            transform: scale(1);
+        }
+
+        .ease-in {
+            transition-timing-function: cubic-bezier(0.4, 0, 1, 1);
+        }
+
+        .ease-out {
+            transition-timing-function: cubic-bezier(0, 0, 0.2, 1);
+        }
+
+    </style>
+
+    <script
+        src="https://polyfill.io/v3/polyfill.min.js?features=MutationObserver%2CArray.from%2CArray.prototype.forEach%2CMap%2CSet%2CArray.prototype.includes%2CString.prototype.includes%2CPromise%2CNodeList.prototype.forEach%2CObject.values%2CReflect%2CReflect.set%2CString.prototype.startsWith%2CArray.prototype.find%2CArray.prototype.findIndex%2CElement.prototype.closest%2CElement.prototype.remove">
+    </script>
+
+    <script>
+    // source: https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent
+;(function() {
+  if (typeof window.CustomEvent === "function") return false
+
+  function CustomEvent(event, params) {
+    params = params || { bubbles: false, cancelable: false, detail: undefined }
+    var evt = document.createEvent("CustomEvent")
+    evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail)
+    return evt
+  }
+
+  CustomEvent.prototype = window.Event.prototype
+
+  window.CustomEvent = CustomEvent
+})()
+    
+    
+    </script>
+
+    <script src="https://cdn.jsdelivr.net/npm/proxy-polyfill@0.3.0/proxy.min.js"></script>
+
+    <script src="/dist/alpine-ie11.js"></script>
+    <!--
+    <script src="https://cdn.jsdelivr.net/gh/alpinejs/alpine@v0.4.0/dist/project-x.js" defer></script>
+    -->
+</head>
+
+<body>
+
+
+
+    <h2>Dispatch 1</h2>
+
+
+    <div x-data="{ foo: 'bar' }" x-on:custom-event="foo = $event.detail.newValue">
+        <span x-text="foo"></span>
+
+        <button x-on:click="$dispatch('custom-event', {newValue: 'bazil'})">Turn 'bar' to 'baz'</button>
+    </div>
+
+    <h2>Dispatch 2</h2>
+
+    <div x-data="{}" x-on:custom-event="alert('hello')">
+        <button x-on:click="$dispatch('custom-event')">Send Alert</button>
+    </div>
+    
+
+    <h2>Binding</h2>
+
+    <div x-data="{ foo: 'bar'}">
+        Text:
+        <span x-text="JSON.stringify(foo)"></span>
+        <input type="text" x-model="foo">
+    </div>
+
+
+
+</body>
+
+</html>

+ 1 - 1
src/directives/model.js

@@ -27,7 +27,7 @@ function generateModelAssignmentFunction(el, modifiers, expression) {
     }
 
     return (event, currentValue) => {
-        if (event instanceof CustomEvent) {
+        if (event instanceof CustomEvent && event.detail) {
             return event.detail
         } else if (el.type === 'checkbox') {
             // If the data we are binding to is an array, toggle it's value inside the array.

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است