Browse Source

Cleanup PR

Caleb Porzio 5 years ago
parent
commit
6cf21664db

File diff suppressed because it is too large
+ 0 - 0
dist/alpine-ie11.js


File diff suppressed because it is too large
+ 0 - 0
dist/alpine-ie11.js.map


File diff suppressed because it is too large
+ 0 - 0
dist/alpine.js


File diff suppressed because it is too large
+ 0 - 0
dist/alpine.js.map


+ 4 - 0
examples/index.html

@@ -13,6 +13,10 @@
             .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 for testing IE11 support: -->
+        <!-- <script src="/dist/alpine_ie11.js" defer></script> -->
+
         <script src="/dist/alpine.js" defer></script>
     </head>
     <body>

+ 0 - 345
examples/index_ie11.html

@@ -1,345 +0,0 @@
-<!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="/dist/alpine_ie11.js" defer></script>
-</head>
-
-<body>
-    <table>
-        <thead>
-            <tr>
-                <th>Feature</th>
-                <th>Demo</th>
-            </tr>
-        </thead>
-        <tbody>
-            <tr>
-                <td>Simple x-if</td>
-                <td>
-                    <div x-data="{ show: false }">
-                        <template x-if="show">
-                            <span>hey</span>
-                        </template>
-
-                        <button @click="show = ! show">Show</button>
-                    </div>
-                </td>
-            </tr>
-
-            <tr>
-                <td>Dropdown</td>
-                <td>
-                    <div x-data="{ open: false }">
-                        <button x-on:click="open= true">Open Dropdown</button>
-                            <ul
-                                x-bind:class="{ 'hidden': ! open }"
-                                x-on:click.away="open= false"
-                                x-cloak>
-                            Dropdown Body
-                        </ul>
-                    </div>
-                </td>
-            </tr>
-
-            <tr>
-                <td>Tabs</td>
-                <td>
-                    <div x-data="{ currentTab: 'tab1' }">
-                        <button x-bind:class="{ 'active': currentTab ===
-                                'tab1' }" x-on:click="currentTab= 'tab1'">Foo</button>
-                        <button x-bind:class="{ 'active': currentTab ===
-                                'tab2' }" x-on:click="currentTab= 'tab2'">Bar</button>
-                        <div x-bind:class="{ 'hidden': currentTab !== 'tab1'
-                                }">Tab Foo</div>
-                        <div class="hidden" x-bind:class="{ 'hidden':
-                                currentTab !== 'tab2' }">Tab Bar</div>
-                    </div>
-                </td>
-            </tr>
-
-            <tr>
-                <td>Data Binding</td>
-                <td>
-                    <div x-data="{ text: 'foo', checkbox: ['foo'], radio:
-                            'foo', select: 'foo', 'multiselect': ['foo'] }">
-                        Text:
-                        <span x-text="JSON.stringify(text)"></span>
-                        <input type="text" x-model="text">
-                        Checkbox:
-                        <span x-text="JSON.stringify(checkbox)"></span>
-                        <input type="checkbox" x-model="checkbox" value="foo">
-                        <input type="checkbox" x-model="checkbox" value="bar">
-                        Radio:
-                        <span x-text="JSON.stringify(radio)"></span>
-                        <input type="radio" x-model="radio" value="foo">
-                        <input type="radio" x-model="radio" value="bar">
-                        Select:
-                        <span x-text="JSON.stringify(select)"></span>
-                        <select x-model="select">
-                            <option>foo</option>
-                            <option>bar</option>
-                        </select>
-                        Multiple Select:
-                        <span x-text="JSON.stringify(multiselect)"></span>
-                        <select x-model="multiselect" multiple>
-                            <option>foo</option>
-                            <option>bar</option>
-                        </select>
-                    </div>
-                </td>
-            </tr>
-
-            <tr>
-                <td>Cast to number</td>
-                <td>
-                    <div x-data="{ number: 1 }">
-                        <div x-text="JSON.stringify($data.number)"></div>
-                        <input type="text" x-model.number="number">
-                    </div>
-                </td>
-            </tr>
-
-            <tr>
-                <td>Nested Binding</td>
-                <td>
-                    <div x-data="{ foo: { bar: 'baz' } }">
-                        <div x-text="foo.bar"></div>
-                        <input type="text" x-model="foo.bar">
-                    </div>
-                </td>
-            </tr>
-
-            <tr>
-                <td>On Click</td>
-                <td>
-                    <div x-data="{ show: false }">
-                        <div x-show="show">Hi There!</div>
-
-                        <button x-on:click="show= ! show">Show/Hide</button>
-                    </div>
-                </td>
-            </tr>
-
-            <tr>
-                <td>Refs</td>
-                <td>
-                    <div x-data="{ someText: 'bar' }">
-                        <div x-ref="remove-target">Remove Me</div>
-
-                            <button
-                                x-on:click="$refs['remove-target'].remove()">Remove</button>
-                    </div>
-                </td>
-            </tr>
-
-            <tr>
-                <td>x-on:click.stop</td>
-                <td>
-                    <div x-data="{ someText: 'bar' }">
-                        <span x-text="someText"></span>
-
-                        <div x-on:click="someText= 'baz'">
-                            <button x-on:click.stop>Shouldn't change to baz</button>
-                        </div>
-
-                    </div>
-                </td>
-            </tr>
-
-            <tr>
-                <td>x-on:click.prevent</td>
-                <td>
-                    <div x-data="{}">
-                        <a href="https://google.com" x-on:click.prevent>Shouldn't
-                            go to Google</a>
-                    </div>
-                </td>
-            </tr>
-
-            <tr>
-                <td>x-on:click.once</td>
-                <td>
-                    <div x-data="{ count: 0 }">
-                        <button x-on:click.once="count++">I've been clicked:
-                            <span x-text="count"></span></button>
-                    </div>
-                </td>
-            </tr>
-
-            <tr>
-                <td>Append DOM</td>
-                <td>
-                    <div id="goHere">Click me.</div>
-                    <script>
-                        const thing = document.querySelector('#goHere')
-                        const handler = function (e) {
-                            thing.removeEventListener('click', handler)
-
-                            const div = document.createElement('div')
-                            div.setAttribute('x-data', '{hey: "there"}')
-                            div.innerHTML = '<input type="text" x-model="hey"><h1 x-text="hey"></h1>'
-                            e.target.appendChild(div)
-                        }
-
-                        var listener = thing.addEventListener('click', handler)
-
-                    </script>
-                </td>
-            </tr>
-
-            <tr>
-                <td>x-for</td>
-                <td>
-                    <div x-data="{ items: ['foo', 'bar'], foo: 'bar' }">
-                        <input type="checkbox" x-model="items" value="foo">
-                        <input type="checkbox" x-model="items" value="bar">
-                        <input type="checkbox" x-model="items" value="baz">
-
-                        <button @click="items = ['bar', 'bob']">hey</button>
-
-                        <template x-for="item in items" :key="item">
-                            <div x-text="item" x-transition:enter-start="opacity-0 scale-90"
-                                x-transition:enter="ease-out transition-medium"
-                                x-transition:enter-end="opacity-100 scale-100"
-                                x-transition:leave-start="opacity-100 scale-100"
-                                x-transition:leave="ease-in transition-faster"
-                                x-transition:leave-end="opacity-0 scale-90"
-                            ></div>
-                        </template>
-                    </div>
-                </td>
-            </tr>
-
-            <tr>
-                <td>Transitions</td>
-                <td>
-                    <div x-data="{ open: false }">
-                        <button x-on:click="open= ! open">
-                            Open Modal
-                        </button>
-
-                            <div x-show="open"
-                                x-transition:enter="transition-medium"
-                            x-transition:leave="transition-medium">
-                                <div x-show="open"
-                                    x-transition:enter="transition-medium"
-                                    x-transition:enter-start="opacity-0"
-                                    x-transition:leave-end="opacity-0"
-                                x-transition:leave="transition-medium"></div>
-                                <div x-show="open"
-                                    x-transition:enter-start="opacity-0 scale-90"
-                                x-transition:enter="ease-out transition-medium"
-                                x-transition:enter-end="opacity-100 scale-100"
-                                x-transition:leave-start="opacity-100 scale-100"
-                                x-transition:leave="ease-in transition-faster"
-                                x-transition:leave-end="opacity-0 scale-90">
-                                <div>
-                                    hey
-                                </div>
-                                <div>
-                                    <button x-on:click="open= false" type="button">
-                                        Cancel
-                                    </button>
-                                </div>
-                            </div>
-                        </div>
-                    </div>
-                </td>
-            </tr>
-
-            <tr>
-                <td>Transitions (with x-if)</td>
-                <td>
-                    <div x-data="{ open: false }">
-                        <button x-on:click="open= ! open">
-                            Open Modal
-                        </button>
-
-                        <template x-if="open">
-                            <div x-transition:enter-start="opacity-0 scale-90"
-                                x-transition:enter="ease-out transition-medium"
-                                x-transition:enter-end="opacity-100 scale-100"
-                                x-transition:leave-start="opacity-100 scale-100"
-                                x-transition:leave="ease-in transition-faster"
-                                x-transition:leave-end="opacity-0 scale-90">
-                                hey
-                            </div>
-                        </template>
-                    </div>
-                </td>
-            </tr>
-            <tr>
-                <td>Init function callback access refs and mutate data</td>
-                <td>
-                    <div x-data="initialData()" x-init="init()">
-                        <div :style="'width: '+width+'px; background: purple;'">hey</div>
-                        <button x-on:click="console.log($refs.inc)">Click for ref</button>
-                        <button x-ref="inc" x-on:click="increaseSize()">Increase bar</button>
-
-                        <span x-ref="status">status</span>
-                    </div>
-
-                    <script>
-                        function initialData() {
-                            return {
-                                width: 20,
-                                init: function () {
-                                    this.$refs.inc.addEventListener('click', function () {
-                                        this.width = this.width + 20
-                                    })
-                                },
-                                increaseSize: function () {
-                                    this.width = this.width + 20
-                                    this.$refs.status.innerText = "expanded";
-                                    console.log(this.$refs.status)
-                                }
-                            }
-                        }
-
-                    </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>
-                <td>
-                    <div x-data="{}" x-cloak>
-                        I'm cloaked
-                    </div>
-                </td>
-            </tr>
-        </tbody>
-    </table>
-
-
-
-</body>
-
-</html>

+ 30 - 11
package-lock.json

@@ -4469,7 +4469,8 @@
         "ansi-regex": {
           "version": "2.1.1",
           "bundled": true,
-          "dev": true
+          "dev": true,
+          "optional": true
         },
         "aproba": {
           "version": "1.2.0",
@@ -4490,12 +4491,14 @@
         "balanced-match": {
           "version": "1.0.0",
           "bundled": true,
-          "dev": true
+          "dev": true,
+          "optional": true
         },
         "brace-expansion": {
           "version": "1.1.11",
           "bundled": true,
           "dev": true,
+          "optional": true,
           "requires": {
             "balanced-match": "^1.0.0",
             "concat-map": "0.0.1"
@@ -4510,17 +4513,20 @@
         "code-point-at": {
           "version": "1.1.0",
           "bundled": true,
-          "dev": true
+          "dev": true,
+          "optional": true
         },
         "concat-map": {
           "version": "0.0.1",
           "bundled": true,
-          "dev": true
+          "dev": true,
+          "optional": true
         },
         "console-control-strings": {
           "version": "1.1.0",
           "bundled": true,
-          "dev": true
+          "dev": true,
+          "optional": true
         },
         "core-util-is": {
           "version": "1.0.2",
@@ -4637,7 +4643,8 @@
         "inherits": {
           "version": "2.0.3",
           "bundled": true,
-          "dev": true
+          "dev": true,
+          "optional": true
         },
         "ini": {
           "version": "1.3.5",
@@ -4649,6 +4656,7 @@
           "version": "1.0.0",
           "bundled": true,
           "dev": true,
+          "optional": true,
           "requires": {
             "number-is-nan": "^1.0.0"
           }
@@ -4663,6 +4671,7 @@
           "version": "3.0.4",
           "bundled": true,
           "dev": true,
+          "optional": true,
           "requires": {
             "brace-expansion": "^1.1.7"
           }
@@ -4670,12 +4679,14 @@
         "minimist": {
           "version": "0.0.8",
           "bundled": true,
-          "dev": true
+          "dev": true,
+          "optional": true
         },
         "minipass": {
           "version": "2.3.5",
           "bundled": true,
           "dev": true,
+          "optional": true,
           "requires": {
             "safe-buffer": "^5.1.2",
             "yallist": "^3.0.0"
@@ -4694,6 +4705,7 @@
           "version": "0.5.1",
           "bundled": true,
           "dev": true,
+          "optional": true,
           "requires": {
             "minimist": "0.0.8"
           }
@@ -4774,7 +4786,8 @@
         "number-is-nan": {
           "version": "1.0.1",
           "bundled": true,
-          "dev": true
+          "dev": true,
+          "optional": true
         },
         "object-assign": {
           "version": "4.1.1",
@@ -4786,6 +4799,7 @@
           "version": "1.4.0",
           "bundled": true,
           "dev": true,
+          "optional": true,
           "requires": {
             "wrappy": "1"
           }
@@ -4871,7 +4885,8 @@
         "safe-buffer": {
           "version": "5.1.2",
           "bundled": true,
-          "dev": true
+          "dev": true,
+          "optional": true
         },
         "safer-buffer": {
           "version": "2.1.2",
@@ -4907,6 +4922,7 @@
           "version": "1.0.2",
           "bundled": true,
           "dev": true,
+          "optional": true,
           "requires": {
             "code-point-at": "^1.0.0",
             "is-fullwidth-code-point": "^1.0.0",
@@ -4926,6 +4942,7 @@
           "version": "3.0.1",
           "bundled": true,
           "dev": true,
+          "optional": true,
           "requires": {
             "ansi-regex": "^2.0.0"
           }
@@ -4969,12 +4986,14 @@
         "wrappy": {
           "version": "1.0.2",
           "bundled": true,
-          "dev": true
+          "dev": true,
+          "optional": true
         },
         "yallist": {
           "version": "3.0.3",
           "bundled": true,
-          "dev": true
+          "dev": true,
+          "optional": true
         }
       }
     },

+ 2 - 2
package.json

@@ -7,8 +7,8 @@
         "url": "git://github.com/alpinejs/alpine.git"
     },
     "scripts": {
-        "watch": "concurrently \"rollup -c -w\" \"npx rollup -c rollup_ie11.config.js -w\"",
-        "build": "concurrently \"rollup -c\" \"npx rollup -c rollup_ie11.config.js\"",
+        "watch": "concurrently \"rollup -c -w\" \"npx rollup -c rollup-ie11.config.js -w\"",
+        "build": "concurrently \"rollup -c\" \"npx rollup -c rollup-ie11.config.js\"",
         "test": "npx jest",
         "test:debug": "node --inspect node_modules/.bin/jest --runInBand",
         "postpublish": "PACKAGE_VERSION=$(cat package.json | grep \\\"version\\\" | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]') && git tag v$PACKAGE_VERSION && git push --tags"

+ 4 - 7
rollup_ie11.config.js → rollup-ie11.config.js

@@ -1,18 +1,15 @@
 import babel from 'rollup-plugin-babel';
 import filesize from 'rollup-plugin-filesize';
-import {
-    terser
-} from "rollup-plugin-terser";
+import { terser } from "rollup-plugin-terser";
 import resolve from "rollup-plugin-node-resolve"
 import commonjs from '@rollup/plugin-commonjs'
 import multi from '@rollup/plugin-multi-entry';
 
-
-export default [{
+export default {
     input: ['src/polyfills.js', 'src/index.js'],
     output: {
         name: 'Alpine',
-        file: 'dist/alpine_ie11.js',
+        file: 'dist/alpine-ie11.js',
         format: 'umd',
         sourcemap: true,
     },
@@ -50,4 +47,4 @@ export default [{
             ]
         })
     ]
-}]
+}

+ 26 - 28
rollup.config.js

@@ -4,31 +4,29 @@ import { terser } from "rollup-plugin-terser";
 import resolve from "rollup-plugin-node-resolve"
 import stripCode from 'rollup-plugin-strip-code';
 
-
-export default [{
-        input: 'src/index.js',
-        output: {
-            name: 'Alpine',
-            file: 'dist/alpine.js',
-            format: 'umd',
-            sourcemap: true,
-        },
-        plugins: [
-            resolve(),
-            filesize(),
-            terser({
-                mangle: false,
-                compress: {
-                    drop_debugger: false,
-                },
-            }),
-            babel({
-                exclude: 'node_modules/**'
-            }),
-            stripCode({
-                start_comment: 'IE11-ONLY:START',
-                end_comment: 'IE11-ONLY:END'
-            })
-        ]
-    }
-]
+export default {
+    input: 'src/index.js',
+    output: {
+        name: 'Alpine',
+        file: 'dist/alpine.js',
+        format: 'umd',
+        sourcemap: true,
+    },
+    plugins: [
+        resolve(),
+        filesize(),
+        terser({
+            mangle: false,
+            compress: {
+                drop_debugger: false,
+            },
+        }),
+        babel({
+            exclude: 'node_modules/**'
+        }),
+        stripCode({
+            start_comment: 'IE11-ONLY:START',
+            end_comment: 'IE11-ONLY:END'
+        })
+    ]
+}

+ 3 - 5
src/component.js

@@ -20,7 +20,7 @@ export default class Component {
 
         /* IE11-ONLY:START */
             // For IE11, add our magic properties to the original data for access.
-            // Since the polyfill proxy does not allow properties to be added after creation
+            // The Proxy pollyfill does not allow properties to be added after creation.
             unobservedData.$el = null
             unobservedData.$refs = null
             unobservedData.$nextTick = null
@@ -347,13 +347,12 @@ export default class Component {
         var refObj = {}
 
         /* IE11-ONLY:START */
-            //add any properties that might be necessary for ie11 proxy
+            // Add any properties up-front that might be necessary for the Proxy pollyfill.
             refObj.$isRefsProxy = false;
             refObj.$isAlpineProxy = false;
 
             // If we are in IE, since the polyfill needs all properties to be defined before building the proxy,
-            // we just loop on the element, look for any x-ref and create a the property on a fake object.
-            // We don't need to put a real value since it will be resolved by the proxy class
+            // we just loop on the element, look for any x-ref and create a tmp property on a fake object.
             this.walkAndSkipNestedComponents(self.$el, el => {
                 if (el.hasAttribute('x-ref')) {
                     refObj[el.getAttribute('x-ref')] = true
@@ -361,7 +360,6 @@ export default class Component {
             })
         /* IE11-ONLY:END */
 
-
         // One of the goals of this is to not hold elements in memory, but rather re-evaluate
         // the DOM when the system needs something from it. This way, the framework is flexible and
         // friendly to outside DOM changes from libraries like Vue/Livewire.

+ 1 - 1
src/directives/model.js

@@ -27,7 +27,7 @@ function generateModelAssignmentFunction(el, modifiers, expression) {
     }
 
     return (event, currentValue) => {
-        //check for event.detail. due to an issue where IE11 handles the event as a CustomEvent. The event should be undefined
+        // Check for event.detail due to an issue where IE11 handles other events as a CustomEvent.
         if (event instanceof CustomEvent && event.detail) {
             return event.detail
         } else if (el.type === 'checkbox') {

+ 2 - 3
src/polyfills.js

@@ -1,9 +1,8 @@
-// In use in the legacy build for IE11
-
+// For the IE11 build.
 import "shim-selected-options"
 import "proxy-polyfill/proxy.min.js"
 import "element-closest/browser.js"
 import "element-remove"
 import "classlist-polyfill"
 import "@webcomponents/template"
-import "custom-event-polyfill"
+import "custom-event-polyfill"

Some files were not shown because too many files changed in this diff