Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
taufik-nurrohman committed Jan 8, 2021
1 parent d2d77b9 commit 348ac79
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 26 deletions.
13 changes: 6 additions & 7 deletions .source/-/index.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {D, R, W, fromElement, getAttribute, getElement, getElements, getName, getNext, getText, hasAttribute, hasParent, isWindow, letElement, setChildLast, setElement, setNext, setPrev, theHistory, theLocation, theScript, toElement} from '@taufik-nurrohman/document';
import {eventPreventDefault, off as offEvent, on as onEvent} from '@taufik-nurrohman/event';
import {fromStates, fromValue} from '@taufik-nurrohman/from';
import {fire as fireHook, hooks, off as offHook, on as onHook} from '@taufik-nurrohman/hook';
import {fire as fireHook, hooks as theHooks, off as offHook, on as onHook} from '@taufik-nurrohman/hook';
import {isBoolean, isFunction, isInstance, isObject, isSet} from '@taufik-nurrohman/is';
import {toPattern} from '@taufik-nurrohman/pattern';
import {getOffset, setScroll} from '@taufik-nurrohman/rect';
Expand Down Expand Up @@ -148,12 +148,11 @@ function toID(text) {
function toHeadersAsProxy(request) {
let out = {},
headers = request.getAllResponseHeaders().trim().split(/[\r\n]+/),
header, h, k, v, w;
header, h, k;
for (header in headers) {
h = headers[header].split(': ');
k = toCaseLower(h.shift());
w = toCaseLower(v = h.join(': '));
out[k] = toValue(v);
out[k] = toValue(h.join(': '));
}
// Use proxy to make case-insensitive response header’s key
return new Proxy(out, {
Expand Down Expand Up @@ -407,7 +406,7 @@ function F3H(source = D, state = {}) {

// Focus to the first element that has `autofocus` attribute
function doFocusToElement(data) {
if (hooks.focus) {
if (theHooks.focus) {
fire('focus', data);
return;
}
Expand Down Expand Up @@ -440,7 +439,7 @@ function F3H(source = D, state = {}) {

// Scroll to the first element with `id` or `name` attribute that has the same value as location hash
function doScrollToElement(data) {
if (hooks.scroll) {
if (theHooks.scroll) {
fire('scroll', data);
return;
}
Expand Down Expand Up @@ -593,7 +592,7 @@ function F3H(source = D, state = {}) {
$.caches = caches;
$.fetch = (ref, type, from) => doFetchBase(from, type, ref);
$.fire = fire;
$.hooks = hooks;
$.hooks = theHooks;
$.links = links;
$.lot = null;
$.off = off;
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Contribute
Release Notes
-------------

### 1.1.12

- Updated.

### 1.1.11

- Restructured the test files.
Expand Down
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html><html dir="ltr"><head><meta charset="utf-8"><meta content="#000" name="theme-color"><meta content="width=device-width" name="viewport"><meta content="Load pages asynchronously using AJAX while maintaining the principles of progressive enhancement." name="description"><title>Fetch 1.1.11</title><style>* {
<!DOCTYPE html><html dir="ltr"><head><meta charset="utf-8"><meta content="#000" name="theme-color"><meta content="width=device-width" name="viewport"><meta content="Load pages asynchronously using AJAX while maintaining the principles of progressive enhancement." name="description"><title>Fetch 1.1.12</title><style>* {
box-sizing: border-box;
}
:root {
Expand Down Expand Up @@ -49,7 +49,7 @@
border: 1px dashed;
margin-top: 0;
padding: .75em 1em;
}</style></head><body><p>Do you like this project? Please support my <a href="https://github.com/mecha-cms">Mecha CMS</a> project too. Thank you!</p><header><h1>Fetch 1.1.11</h1><p>You can read <abbr title="Fetch">F3H</abbr> as how you would read <abbr title="Accessibility">A11Y</abbr> and <abbr title="Internationalization">I18N</abbr>.</p><p>Your job is to make a website that works traditionally: clicking on a link will direct you to a new page, sending and uploading data through a form will store it to the web storage. After you finish making it, this application will serve as a feature enhancer, which is, to enable AJAX features to your traditional web pages automatically, so that your web pages can load faster because you can specify which parts of the destination page you want to load into the current page.</p><hr></header><main><p>Progressive enhancement is a design principle that is focused in ensuring the availability of web page content in the most limited conditions, and if possible, to provide the most advanced features when the conditions are supportive. By enhancing features while maintaining the basic functions of HTML pages, this concept will ensure that if your advanced JavaScript features cannot work optimally under certain conditions, then at least the web page content that you want to provide is still accessible to most users.</p><p><a href="test/1/index.html" target="_blank"><b>Demo</b></a></p><h2>Features</h2><ul><li>Light-weight, no dependencies. It uses vanilla JavaScript.</li><li>Simple <abbr title="Application Programming Interface">API</abbr>. Easy to master.</li><li>Accessible AJAX response as HTML elements (by default).</li><li>Instant click with native HTML5 Prefetch, improved by the power of JavaScript.</li><li>Progressively enhanced. If at any time the JavaScript fails to load, or if users are using an old web browser, or if users decide to disable the JavaScript features, or if some third-party JavaScript makes this application fail to work, your website will still be able to work as when it didn&rsquo;t have any AJAX features.</li></ul><h2>Usage</h2><h3>Browser</h3><p>With the basic knowledge of accessing the DOM and manipulating it using JavaScript, you can use this application like a pro.</p><pre><code>&lt;!DOCTYPE html&gt;
}</style></head><body><p>Do you like this project? Please support my <a href="https://github.com/mecha-cms">Mecha CMS</a> project too. Thank you!</p><header><h1>Fetch 1.1.12</h1><p>You can read <abbr title="Fetch">F3H</abbr> as how you would read <abbr title="Accessibility">A11Y</abbr> and <abbr title="Internationalization">I18N</abbr>.</p><p>Your job is to make a website that works traditionally: clicking on a link will direct you to a new page, sending and uploading data through a form will store it to the web storage. After you finish making it, this application will serve as a feature enhancer, which is, to enable AJAX features to your traditional web pages automatically, so that your web pages can load faster because you can specify which parts of the destination page you want to load into the current page.</p><hr></header><main><p>Progressive enhancement is a design principle that is focused in ensuring the availability of web page content in the most limited conditions, and if possible, to provide the most advanced features when the conditions are supportive. By enhancing features while maintaining the basic functions of HTML pages, this concept will ensure that if your advanced JavaScript features cannot work optimally under certain conditions, then at least the web page content that you want to provide is still accessible to most users.</p><p><a href="test/1/index.html" target="_blank"><b>Demo</b></a></p><h2>Features</h2><ul><li>Light-weight, no dependencies. It uses vanilla JavaScript.</li><li>Simple <abbr title="Application Programming Interface">API</abbr>. Easy to master.</li><li>Accessible AJAX response as HTML elements (by default).</li><li>Instant click with native HTML5 Prefetch, improved by the power of JavaScript.</li><li>Progressively enhanced. If at any time the JavaScript fails to load, or if users are using an old web browser, or if users decide to disable the JavaScript features, or if some third-party JavaScript makes this application fail to work, your website will still be able to work as when it didn&rsquo;t have any AJAX features.</li></ul><h2>Usage</h2><h3>Browser</h3><p>With the basic knowledge of accessing the DOM and manipulating it using JavaScript, you can use this application like a pro.</p><pre><code>&lt;!DOCTYPE html&gt;
&lt;html dir="ltr"&gt;
&lt;head&gt;
&lt;meta charset="utf-8"&gt;
Expand Down
9 changes: 3 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -664,15 +664,12 @@
headers = request.getAllResponseHeaders().trim().split(/[\r\n]+/),
header,
h,
k,
v,
w;
k;

for (header in headers) {
h = headers[header].split(': ');
k = toCaseLower$1(h.shift());
w = toCaseLower$1(v = h.join(': '));
out[k] = toValue$1(v);
out[k] = toValue$1(h.join(': '));
} // Use proxy to make case-insensitive response header’s key


Expand Down Expand Up @@ -1239,6 +1236,6 @@
'JSON': responseTypeJSON
}
};
F3H.version = '1.1.11';
F3H.version = '1.1.12';
return F3H;
});
2 changes: 1 addition & 1 deletion index.min.js

Large diffs are not rendered by default.

15 changes: 7 additions & 8 deletions index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import {D, R, W, fromElement, getAttribute, getElement, getElements, getName, getNext, getText, hasAttribute, hasParent, isWindow, letElement, setChildLast, setElement, setNext, setPrev, theHistory, theLocation, theScript, toElement} from '@taufik-nurrohman/document';
import {eventPreventDefault, off as offEvent, on as onEvent} from '@taufik-nurrohman/event';
import {fromStates, fromValue} from '@taufik-nurrohman/from';
import {fire as fireHook, hooks, off as offHook, on as onHook} from '@taufik-nurrohman/hook';
import {fire as fireHook, hooks as theHooks, off as offHook, on as onHook} from '@taufik-nurrohman/hook';
import {isBoolean, isFunction, isInstance, isObject, isSet} from '@taufik-nurrohman/is';
import {toPattern} from '@taufik-nurrohman/pattern';
import {getOffset, setScroll} from '@taufik-nurrohman/rect';
Expand Down Expand Up @@ -176,12 +176,11 @@ function toID(text) {
function toHeadersAsProxy(request) {
let out = {},
headers = request.getAllResponseHeaders().trim().split(/[\r\n]+/),
header, h, k, v, w;
header, h, k;
for (header in headers) {
h = headers[header].split(': ');
k = toCaseLower(h.shift());
w = toCaseLower(v = h.join(': '));
out[k] = toValue(v);
out[k] = toValue(h.join(': '));
}
// Use proxy to make case-insensitive response header’s key
return new Proxy(out, {
Expand Down Expand Up @@ -435,7 +434,7 @@ function F3H(source = D, state = {}) {

// Focus to the first element that has `autofocus` attribute
function doFocusToElement(data) {
if (hooks.focus) {
if (theHooks.focus) {
fire('focus', data);
return;
}
Expand Down Expand Up @@ -468,7 +467,7 @@ function F3H(source = D, state = {}) {

// Scroll to the first element with `id` or `name` attribute that has the same value as location hash
function doScrollToElement(data) {
if (hooks.scroll) {
if (theHooks.scroll) {
fire('scroll', data);
return;
}
Expand Down Expand Up @@ -621,7 +620,7 @@ function F3H(source = D, state = {}) {
$.caches = caches;
$.fetch = (ref, type, from) => doFetchBase(from, type, ref);
$.fire = fire;
$.hooks = hooks;
$.hooks = theHooks;
$.links = links;
$.lot = null;
$.off = off;
Expand Down Expand Up @@ -701,6 +700,6 @@ F3H.state = {
}
};

F3H.version = '1.1.11';
F3H.version = '1.1.12';

export default F3H;
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@taufik-nurrohman/rect": "^0.0.3",
"@taufik-nurrohman/to": "^0.0.14",
"pug": "^3.0.0",
"rollup": "^2.35.1",
"rollup": "^2.36.1",
"terser": "^5.5.1"
},
"exports": {
Expand Down Expand Up @@ -60,5 +60,5 @@
"js": "node .source/mjs.mjs"
},
"type": "module",
"version": "1.1.11"
"version": "1.1.12"
}

0 comments on commit 348ac79

Please sign in to comment.