Skip to content

Commit 3df522e

Browse files
committed
v10.1.5 => Resolves #229, #245
1 parent 4c808c1 commit 3df522e

22 files changed

+45
-98
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
> Simple autocomplete pure vanilla Javascript library. :rocket: <a href="https://tarekraafat.github.io/autoComplete.js/demo/" target="\_blank">Live Demo</a> **v10**
2525
26-
autoComplete.js is a simple pure vanilla Javascript library that's progressively designed for speed, high versatility and seamless integration with a wide range of projects & systems. <sub><sup>(Made for a better developer experience)</sub></pub>
26+
autoComplete.js is a simple, pure vanilla Javascript library progressively designed for speed, high versatility, and seamless integration with a wide range of projects & systems. <sub><sup>(Made for a better developer experience)</sub></pub>
2727

2828
## Features
2929

@@ -47,13 +47,13 @@ autoComplete.js is a simple pure vanilla Javascript library that's progressively
4747
`JS`
4848

4949
```html
50-
<script src="https://cdn.jsdelivr.net/npm/@tarekraafat/autocomplete.js@10.1.4/dist/autoComplete.min.js"></script>
50+
<script src="https://cdn.jsdelivr.net/npm/@tarekraafat/autocomplete.js@10.1.5/dist/autoComplete.min.js"></script>
5151
```
5252

5353
`CSS`
5454

5555
```html
56-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tarekraafat/autocomplete.js@10.1.4/dist/css/autoComplete.min.css">
56+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tarekraafat/autocomplete.js@10.1.5/dist/css/autoComplete.min.css">
5757
```
5858
#### Package Manager
5959

dist/autoComplete.js

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -186,22 +186,6 @@
186186
ctx.input = typeof ctx.selector === "string" ? document.querySelector(ctx.selector) : ctx.selector();
187187
});
188188

189-
var preInit = (function (ctx) {
190-
var callback = function callback(mutations, observer) {
191-
mutations.forEach(function (mutation) {
192-
if (ctx.input) {
193-
observer.disconnect();
194-
ctx.init();
195-
}
196-
});
197-
};
198-
var observer = new MutationObserver(callback);
199-
observer.observe(document, {
200-
childList: true,
201-
subtree: true
202-
});
203-
});
204-
205189
var select$1 = function select(element) {
206190
return typeof element === "string" ? document.querySelector(element) : element;
207191
};
@@ -641,16 +625,18 @@
641625

642626
function extend (autoComplete) {
643627
var prototype = autoComplete.prototype;
644-
prototype.preInit = function () {
645-
preInit(this);
646-
};
647628
prototype.init = function () {
648629
init(this);
649630
};
650631
prototype.start = function () {
651632
start(this);
652633
};
653634
prototype.unInit = function () {
635+
if (this.wrapper) {
636+
var parentNode = this.wrapper.parentNode;
637+
parentNode.insertBefore(this.input, this.wrapper);
638+
parentNode.removeChild(this.wrapper);
639+
}
654640
removeEvents(this);
655641
};
656642
prototype.open = function () {
@@ -693,8 +679,7 @@
693679
};
694680
configure(this);
695681
extend.call(this, autoComplete);
696-
var run = this.observe ? preInit : init;
697-
run(this);
682+
init(this);
698683
}
699684

700685
return autoComplete;

dist/autoComplete.js.gz

-83 Bytes
Binary file not shown.

dist/autoComplete.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/autoComplete.min.js.gz

-59 Bytes
Binary file not shown.

docs/demo/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
<meta name="msapplication-TileImage" content="/ms-icon-144x144.png">
7373
<meta name="theme-color" content="#ffffff">
7474
<link rel="stylesheet" type="text/css" media="screen"
75-
href="https://cdn.jsdelivr.net/npm/@tarekraafat/autocomplete.js@10.1.4/dist/css/autoComplete.min.css">
75+
href="https://cdn.jsdelivr.net/npm/@tarekraafat/autocomplete.js@10.1.5/dist/css/autoComplete.min.css">
7676
<!-- <link rel="stylesheet" type="text/css" media="screen" href="./css/autoComplete.css"> -->
7777
<link rel="stylesheet" type="text/css" media="screen" href="./css/main.css">
7878
<link href="https://fonts.googleapis.com/css?family=PT+Sans" rel="stylesheet">
@@ -150,7 +150,7 @@ <h4>mode</h4>
150150
</div>
151151
</footer>
152152
</div>
153-
<script src="https://cdn.jsdelivr.net/npm/@tarekraafat/autocomplete.js@10.1.4/dist/autoComplete.min.js"></script>
153+
<script src="https://cdn.jsdelivr.net/npm/@tarekraafat/autocomplete.js@10.1.5/dist/autoComplete.min.js"></script>
154154
<!-- <script src="./js/autoComplete.js"></script> -->
155155
<script src="./js/index.js"></script>
156156
</body>

docs/demo/js/autoComplete.js

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -186,22 +186,6 @@
186186
ctx.input = typeof ctx.selector === "string" ? document.querySelector(ctx.selector) : ctx.selector();
187187
});
188188

189-
var preInit = (function (ctx) {
190-
var callback = function callback(mutations, observer) {
191-
mutations.forEach(function (mutation) {
192-
if (ctx.input) {
193-
observer.disconnect();
194-
ctx.init();
195-
}
196-
});
197-
};
198-
var observer = new MutationObserver(callback);
199-
observer.observe(document, {
200-
childList: true,
201-
subtree: true
202-
});
203-
});
204-
205189
var select$1 = function select(element) {
206190
return typeof element === "string" ? document.querySelector(element) : element;
207191
};
@@ -641,16 +625,18 @@
641625

642626
function extend (autoComplete) {
643627
var prototype = autoComplete.prototype;
644-
prototype.preInit = function () {
645-
preInit(this);
646-
};
647628
prototype.init = function () {
648629
init(this);
649630
};
650631
prototype.start = function () {
651632
start(this);
652633
};
653634
prototype.unInit = function () {
635+
if (this.wrapper) {
636+
var parentNode = this.wrapper.parentNode;
637+
parentNode.insertBefore(this.input, this.wrapper);
638+
parentNode.removeChild(this.wrapper);
639+
}
654640
removeEvents(this);
655641
};
656642
prototype.open = function () {
@@ -693,8 +679,7 @@
693679
};
694680
configure(this);
695681
extend.call(this, autoComplete);
696-
var run = this.observe ? preInit : init;
697-
run(this);
682+
init(this);
698683
}
699684

700685
return autoComplete;

docs/demo/js/autoComplete.js.gz

-83 Bytes
Binary file not shown.

docs/demo/js/autoComplete.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/demo/js/autoComplete.min.js.gz

-59 Bytes
Binary file not shown.

docs/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@
158158
src="//platform-api.sharethis.com/js/sharethis.js#property=5c213660c276020011d38212&product=inline-share-buttons"
159159
async="async"></script>
160160
<link rel="stylesheet"
161-
href="https://cdn.jsdelivr.net/npm/@tarekraafat/autocomplete.js@10.1.4/dist/css/autoComplete.min.css">
161+
href="https://cdn.jsdelivr.net/npm/@tarekraafat/autocomplete.js@10.1.5/dist/css/autoComplete.min.css">
162162
</head>
163163

164164
<body>
@@ -209,7 +209,7 @@
209209
mustache: {
210210
data: ["../package.json", {
211211
minVersion: "10.1",
212-
version: "10.1.4"
212+
version: "10.1.5"
213213
}]
214214
}
215215
}
@@ -224,7 +224,7 @@
224224
<script src="https://cdn.jsdelivr.net/npm/docsify-example-panels"></script>
225225
<script src="//cdn.jsdelivr.net/npm/codeblock-iframe@latest/dist/index.min.js"></script>
226226
<script src="//cdn.jsdelivr.net/npm/docsify-codeblock-iframe@latest/dist/index.min.js"></script>
227-
<script src="https://cdn.jsdelivr.net/npm/@tarekraafat/autocomplete.js@10.1.4/dist/autoComplete.min.js"></script>
227+
<script src="https://cdn.jsdelivr.net/npm/@tarekraafat/autocomplete.js@10.1.5/dist/autoComplete.min.js"></script>
228228
</body>
229229

230230
</html>

docs/index.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@
3232
3333
## What it is? <!-- {docsify-ignore} -->
3434

35-
autoComplete.js is a simple pure vanilla Javascript library that's progressively designed for speed,
36-
high versatility and seamless integration with a wide range of projects & systems.
35+
autoComplete.js is a simple, pure vanilla Javascript library progressively designed for speed, high versatility, and seamless integration with a wide range of projects & systems. <sub><sup>(Made for a better developer experience)</sub></pub>
3736

3837
## Features <!-- {docsify-ignore} -->
3938

docs/release-notes.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@ For more information on semantic versioning, please visit <http://semver.org/>.
3535

3636
***
3737

38-
### v10.1.4 ✨
39-
- 🔧 Fixed: Unresolved dependencies when building a svelte app (Thanks 👍 @sunshineplan) #243
38+
### v10.1.5 ✨
39+
- 🧹 Removed: `preInit` stage (Thanks 👍 @folknor) #229
40+
- 🔧 Fixed: `unInit` to remove the `wrapper` element (Thanks 👍 @deniseismo) #245
41+
42+
### v10.1.4
43+
- 🔧 Fixed: Unresolved dependencies when building a Svelte app (Thanks 👍 @sunshineplan) #243
4044

4145
### v10.1.3
4246
- 🔧 Fixed: `mark` tag's invalid "classes" to "class" attribute (Thanks 👍 @50kudos) #242

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "10.1.4",
2+
"version": "10.1.5",
33
"name": "@tarekraafat/autocomplete.js",
44
"description": "Simple autocomplete pure vanilla Javascript library.",
55
"keywords": [

src/autoComplete.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import configure from "./services/configure";
22
import extend from "./services/extend";
3-
import preInit from "./services/preInit";
43
import init from "./services/init";
54

65
/**
@@ -66,8 +65,6 @@ export default function autoComplete(config) {
6665
configure(this);
6766
// Stage API methods
6867
extend.call(this, autoComplete);
69-
// Set to run "preInit" if "observer" enabled else "init"
70-
const run = this.observe ? preInit : init;
71-
// Run autoComplete.js
72-
run(this);
68+
// Initialize autoComplete.js
69+
init(this);
7370
}

src/controllers/listController.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ const navigate = function (event, ctx) {
273273
case 27:
274274
event.preventDefault();
275275

276-
// Clear "inputField" value
276+
// Clear "input" value
277277
ctx.input.value = "";
278278

279279
close(ctx);

src/helpers/eventEmitter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
* @param {Object} ctx - autoComplete.js context
66
*/
77
export default (name, ctx) => {
8-
// Dispatch event on "inputField"
8+
// Dispatch event on "input"
99
ctx.input.dispatchEvent(new CustomEvent(name, { bubbles: true, detail: ctx.feedback, cancelable: true }));
1010
};

src/helpers/io.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const create = (tag, options) => {
4444
};
4545

4646
/**
47-
* Get the "inputField" query value
47+
* Get the "input" query value
4848
*
4949
* @param {Element} field - input or textarea element
5050
*
@@ -59,7 +59,7 @@ const getQuery = (field) =>
5959
* @param {String} value - user's raw search query value
6060
* @param {Object} diacritics - formatting on/off
6161
*
62-
* @returns {String} - Raw "inputField" value as a string
62+
* @returns {String} - Raw "input" value as a string
6363
*/
6464
const format = (value, diacritics) => {
6565
value = value.toString().toLowerCase();

src/services/extend.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import preInit from "./preInit";
21
import init from "./init";
32
import start from "./start";
43
import { removeEvents } from "../controllers/eventController";
@@ -13,11 +12,6 @@ import search from "../controllers/searchController";
1312
export default function (autoComplete) {
1413
const { prototype } = autoComplete;
1514

16-
// Pre-Initialize autoComplete.js engine
17-
prototype.preInit = function () {
18-
preInit(this);
19-
};
20-
2115
// Initialize autoComplete.js engine
2216
prototype.init = function () {
2317
init(this);
@@ -30,6 +24,13 @@ export default function (autoComplete) {
3024

3125
// Un-Initialize autoComplete.js engine
3226
prototype.unInit = function () {
27+
if (this.wrapper) {
28+
const parentNode = this.wrapper.parentNode;
29+
30+
parentNode.insertBefore(this.input, this.wrapper);
31+
parentNode.removeChild(this.wrapper);
32+
}
33+
3334
removeEvents(this);
3435
};
3536

src/services/init.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default async function (ctx) {
1818
"aria-expanded": false,
1919
};
2020

21-
// Set "inputField" attributes
21+
// Set "input" attributes
2222
create(input, {
2323
"aria-controls": resultsList.id,
2424
"aria-autocomplete": "both",

src/services/preInit.js

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/services/start.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { render, close } from "../controllers/listController";
1010
export default async function (ctx) {
1111
const { input, query, trigger, threshold, resultsList } = ctx;
1212

13-
// Get "inputField" query value
13+
// Get "input" query value
1414
let queryVal = getQuery(input);
1515
queryVal = query ? query(queryVal) : queryVal;
1616
// Get trigger decision

0 commit comments

Comments
 (0)