Skip to content

Commit

Permalink
v10.1.5 => Resolves #229, #245
Browse files Browse the repository at this point in the history
  • Loading branch information
TarekRaafat committed Jun 18, 2021
1 parent 4c808c1 commit 3df522e
Show file tree
Hide file tree
Showing 22 changed files with 45 additions and 98 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

> Simple autocomplete pure vanilla Javascript library. :rocket: <a href="https://tarekraafat.github.io/autoComplete.js/demo/" target="\_blank">Live Demo</a> **v10**
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>
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>

## Features

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

```html
<script src="https://cdn.jsdelivr.net/npm/@tarekraafat/[email protected].4/dist/autoComplete.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@tarekraafat/[email protected].5/dist/autoComplete.min.js"></script>
```

`CSS`

```html
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tarekraafat/[email protected].4/dist/css/autoComplete.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tarekraafat/[email protected].5/dist/css/autoComplete.min.css">
```
#### Package Manager

Expand Down
27 changes: 6 additions & 21 deletions dist/autoComplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,22 +186,6 @@
ctx.input = typeof ctx.selector === "string" ? document.querySelector(ctx.selector) : ctx.selector();
});

var preInit = (function (ctx) {
var callback = function callback(mutations, observer) {
mutations.forEach(function (mutation) {
if (ctx.input) {
observer.disconnect();
ctx.init();
}
});
};
var observer = new MutationObserver(callback);
observer.observe(document, {
childList: true,
subtree: true
});
});

var select$1 = function select(element) {
return typeof element === "string" ? document.querySelector(element) : element;
};
Expand Down Expand Up @@ -641,16 +625,18 @@

function extend (autoComplete) {
var prototype = autoComplete.prototype;
prototype.preInit = function () {
preInit(this);
};
prototype.init = function () {
init(this);
};
prototype.start = function () {
start(this);
};
prototype.unInit = function () {
if (this.wrapper) {
var parentNode = this.wrapper.parentNode;
parentNode.insertBefore(this.input, this.wrapper);
parentNode.removeChild(this.wrapper);
}
removeEvents(this);
};
prototype.open = function () {
Expand Down Expand Up @@ -693,8 +679,7 @@
};
configure(this);
extend.call(this, autoComplete);
var run = this.observe ? preInit : init;
run(this);
init(this);
}

return autoComplete;
Expand Down
Binary file modified dist/autoComplete.js.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion dist/autoComplete.min.js

Large diffs are not rendered by default.

Binary file modified dist/autoComplete.min.js.gz
Binary file not shown.
4 changes: 2 additions & 2 deletions docs/demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
<meta name="msapplication-TileImage" content="/ms-icon-144x144.png">
<meta name="theme-color" content="#ffffff">
<link rel="stylesheet" type="text/css" media="screen"
href="https://cdn.jsdelivr.net/npm/@tarekraafat/[email protected].4/dist/css/autoComplete.min.css">
href="https://cdn.jsdelivr.net/npm/@tarekraafat/[email protected].5/dist/css/autoComplete.min.css">
<!-- <link rel="stylesheet" type="text/css" media="screen" href="./css/autoComplete.css"> -->
<link rel="stylesheet" type="text/css" media="screen" href="./css/main.css">
<link href="https://fonts.googleapis.com/css?family=PT+Sans" rel="stylesheet">
Expand Down Expand Up @@ -150,7 +150,7 @@ <h4>mode</h4>
</div>
</footer>
</div>
<script src="https://cdn.jsdelivr.net/npm/@tarekraafat/[email protected].4/dist/autoComplete.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@tarekraafat/[email protected].5/dist/autoComplete.min.js"></script>
<!-- <script src="./js/autoComplete.js"></script> -->
<script src="./js/index.js"></script>
</body>
Expand Down
27 changes: 6 additions & 21 deletions docs/demo/js/autoComplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,22 +186,6 @@
ctx.input = typeof ctx.selector === "string" ? document.querySelector(ctx.selector) : ctx.selector();
});

var preInit = (function (ctx) {
var callback = function callback(mutations, observer) {
mutations.forEach(function (mutation) {
if (ctx.input) {
observer.disconnect();
ctx.init();
}
});
};
var observer = new MutationObserver(callback);
observer.observe(document, {
childList: true,
subtree: true
});
});

var select$1 = function select(element) {
return typeof element === "string" ? document.querySelector(element) : element;
};
Expand Down Expand Up @@ -641,16 +625,18 @@

function extend (autoComplete) {
var prototype = autoComplete.prototype;
prototype.preInit = function () {
preInit(this);
};
prototype.init = function () {
init(this);
};
prototype.start = function () {
start(this);
};
prototype.unInit = function () {
if (this.wrapper) {
var parentNode = this.wrapper.parentNode;
parentNode.insertBefore(this.input, this.wrapper);
parentNode.removeChild(this.wrapper);
}
removeEvents(this);
};
prototype.open = function () {
Expand Down Expand Up @@ -693,8 +679,7 @@
};
configure(this);
extend.call(this, autoComplete);
var run = this.observe ? preInit : init;
run(this);
init(this);
}

return autoComplete;
Expand Down
Binary file modified docs/demo/js/autoComplete.js.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/demo/js/autoComplete.min.js

Large diffs are not rendered by default.

Binary file modified docs/demo/js/autoComplete.min.js.gz
Binary file not shown.
6 changes: 3 additions & 3 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
src="//platform-api.sharethis.com/js/sharethis.js#property=5c213660c276020011d38212&product=inline-share-buttons"
async="async"></script>
<link rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/@tarekraafat/[email protected].4/dist/css/autoComplete.min.css">
href="https://cdn.jsdelivr.net/npm/@tarekraafat/[email protected].5/dist/css/autoComplete.min.css">
</head>

<body>
Expand Down Expand Up @@ -209,7 +209,7 @@
mustache: {
data: ["../package.json", {
minVersion: "10.1",
version: "10.1.4"
version: "10.1.5"
}]
}
}
Expand All @@ -224,7 +224,7 @@
<script src="https://cdn.jsdelivr.net/npm/docsify-example-panels"></script>
<script src="//cdn.jsdelivr.net/npm/codeblock-iframe@latest/dist/index.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/docsify-codeblock-iframe@latest/dist/index.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@tarekraafat/[email protected].4/dist/autoComplete.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@tarekraafat/[email protected].5/dist/autoComplete.min.js"></script>
</body>

</html>
3 changes: 1 addition & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
## What it is? <!-- {docsify-ignore} -->

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.
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>

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

Expand Down
8 changes: 6 additions & 2 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ For more information on semantic versioning, please visit <http://semver.org/>.

***

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

### v10.1.4
- 🔧 Fixed: Unresolved dependencies when building a Svelte app (Thanks 👍 @sunshineplan) #243

### v10.1.3
- 🔧 Fixed: `mark` tag's invalid "classes" to "class" attribute (Thanks 👍 @50kudos) #242
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "10.1.4",
"version": "10.1.5",
"name": "@tarekraafat/autocomplete.js",
"description": "Simple autocomplete pure vanilla Javascript library.",
"keywords": [
Expand Down
7 changes: 2 additions & 5 deletions src/autoComplete.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import configure from "./services/configure";
import extend from "./services/extend";
import preInit from "./services/preInit";
import init from "./services/init";

/**
Expand Down Expand Up @@ -66,8 +65,6 @@ export default function autoComplete(config) {
configure(this);
// Stage API methods
extend.call(this, autoComplete);
// Set to run "preInit" if "observer" enabled else "init"
const run = this.observe ? preInit : init;
// Run autoComplete.js
run(this);
// Initialize autoComplete.js
init(this);
}
2 changes: 1 addition & 1 deletion src/controllers/listController.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ const navigate = function (event, ctx) {
case 27:
event.preventDefault();

// Clear "inputField" value
// Clear "input" value
ctx.input.value = "";

close(ctx);
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/eventEmitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
* @param {Object} ctx - autoComplete.js context
*/
export default (name, ctx) => {
// Dispatch event on "inputField"
// Dispatch event on "input"
ctx.input.dispatchEvent(new CustomEvent(name, { bubbles: true, detail: ctx.feedback, cancelable: true }));
};
4 changes: 2 additions & 2 deletions src/helpers/io.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const create = (tag, options) => {
};

/**
* Get the "inputField" query value
* Get the "input" query value
*
* @param {Element} field - input or textarea element
*
Expand All @@ -59,7 +59,7 @@ const getQuery = (field) =>
* @param {String} value - user's raw search query value
* @param {Object} diacritics - formatting on/off
*
* @returns {String} - Raw "inputField" value as a string
* @returns {String} - Raw "input" value as a string
*/
const format = (value, diacritics) => {
value = value.toString().toLowerCase();
Expand Down
13 changes: 7 additions & 6 deletions src/services/extend.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import preInit from "./preInit";
import init from "./init";
import start from "./start";
import { removeEvents } from "../controllers/eventController";
Expand All @@ -13,11 +12,6 @@ import search from "../controllers/searchController";
export default function (autoComplete) {
const { prototype } = autoComplete;

// Pre-Initialize autoComplete.js engine
prototype.preInit = function () {
preInit(this);
};

// Initialize autoComplete.js engine
prototype.init = function () {
init(this);
Expand All @@ -30,6 +24,13 @@ export default function (autoComplete) {

// Un-Initialize autoComplete.js engine
prototype.unInit = function () {
if (this.wrapper) {
const parentNode = this.wrapper.parentNode;

parentNode.insertBefore(this.input, this.wrapper);
parentNode.removeChild(this.wrapper);
}

removeEvents(this);
};

Expand Down
2 changes: 1 addition & 1 deletion src/services/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default async function (ctx) {
"aria-expanded": false,
};

// Set "inputField" attributes
// Set "input" attributes
create(input, {
"aria-controls": resultsList.id,
"aria-autocomplete": "both",
Expand Down
24 changes: 0 additions & 24 deletions src/services/preInit.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/services/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { render, close } from "../controllers/listController";
export default async function (ctx) {
const { input, query, trigger, threshold, resultsList } = ctx;

// Get "inputField" query value
// Get "input" query value
let queryVal = getQuery(input);
queryVal = query ? query(queryVal) : queryVal;
// Get trigger decision
Expand Down

0 comments on commit 3df522e

Please sign in to comment.