modularload
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -25,2 +25,40 @@ 'use strict'; | ||
function _slicedToArray(arr, i) { | ||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); | ||
} | ||
function _arrayWithHoles(arr) { | ||
if (Array.isArray(arr)) return arr; | ||
} | ||
function _iterableToArrayLimit(arr, i) { | ||
var _arr = []; | ||
var _n = true; | ||
var _d = false; | ||
var _e = undefined; | ||
try { | ||
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { | ||
_arr.push(_s.value); | ||
if (i && _arr.length === i) break; | ||
} | ||
} catch (err) { | ||
_d = true; | ||
_e = err; | ||
} finally { | ||
try { | ||
if (!_n && _i["return"] != null) _i["return"](); | ||
} finally { | ||
if (_d) throw _e; | ||
} | ||
} | ||
return _arr; | ||
} | ||
function _nonIterableRest() { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance"); | ||
} | ||
var _default = | ||
@@ -34,3 +72,2 @@ /*#__PURE__*/ | ||
name: 'load', | ||
page: 'page', | ||
loadingClass: 'is-loading', | ||
@@ -216,8 +253,17 @@ loadedClass: 'is-loaded', | ||
value: function setAttributes(data) { | ||
var title = data.getElementsByTagName('title')[0].innerHTML; | ||
var description = data.head.querySelector('meta[name="description"]').getAttribute('content'); | ||
var page = data.querySelector('html').getAttribute('data-' + this.page); | ||
document.title = title; | ||
document.head.querySelector('meta[name="description"]').setAttribute('content', description); | ||
document.querySelector('html').setAttribute('data-' + this.page, page); | ||
var title = data.getElementsByTagName('title')[0]; | ||
var description = data.head.querySelector('meta[name="description"]'); | ||
var datas = Object.assign({}, data.querySelector('html').dataset); | ||
if (title) document.title = title.innerHTML; | ||
if (description) document.head.querySelector('meta[name="description"]').setAttribute('content', description.getAttribute('content')); | ||
if (datas) { | ||
Object.entries(datas).forEach(function (_ref) { | ||
var _ref2 = _slicedToArray(_ref, 2), | ||
key = _ref2[0], | ||
val = _ref2[1]; | ||
document.querySelector('html').setAttribute('data-' + key, val); | ||
}); | ||
} | ||
} | ||
@@ -224,0 +270,0 @@ }, { |
@@ -23,2 +23,40 @@ function _classCallCheck(instance, Constructor) { | ||
function _slicedToArray(arr, i) { | ||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); | ||
} | ||
function _arrayWithHoles(arr) { | ||
if (Array.isArray(arr)) return arr; | ||
} | ||
function _iterableToArrayLimit(arr, i) { | ||
var _arr = []; | ||
var _n = true; | ||
var _d = false; | ||
var _e = undefined; | ||
try { | ||
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { | ||
_arr.push(_s.value); | ||
if (i && _arr.length === i) break; | ||
} | ||
} catch (err) { | ||
_d = true; | ||
_e = err; | ||
} finally { | ||
try { | ||
if (!_n && _i["return"] != null) _i["return"](); | ||
} finally { | ||
if (_d) throw _e; | ||
} | ||
} | ||
return _arr; | ||
} | ||
function _nonIterableRest() { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance"); | ||
} | ||
var _default = | ||
@@ -32,3 +70,2 @@ /*#__PURE__*/ | ||
name: 'load', | ||
page: 'page', | ||
loadingClass: 'is-loading', | ||
@@ -214,8 +251,17 @@ loadedClass: 'is-loaded', | ||
value: function setAttributes(data) { | ||
var title = data.getElementsByTagName('title')[0].innerHTML; | ||
var description = data.head.querySelector('meta[name="description"]').getAttribute('content'); | ||
var page = data.querySelector('html').getAttribute('data-' + this.page); | ||
document.title = title; | ||
document.head.querySelector('meta[name="description"]').setAttribute('content', description); | ||
document.querySelector('html').setAttribute('data-' + this.page, page); | ||
var title = data.getElementsByTagName('title')[0]; | ||
var description = data.head.querySelector('meta[name="description"]'); | ||
var datas = Object.assign({}, data.querySelector('html').dataset); | ||
if (title) document.title = title.innerHTML; | ||
if (description) document.head.querySelector('meta[name="description"]').setAttribute('content', description.getAttribute('content')); | ||
if (datas) { | ||
Object.entries(datas).forEach(function (_ref) { | ||
var _ref2 = _slicedToArray(_ref, 2), | ||
key = _ref2[0], | ||
val = _ref2[1]; | ||
document.querySelector('html').setAttribute('data-' + key, val); | ||
}); | ||
} | ||
} | ||
@@ -222,0 +268,0 @@ }, { |
{ | ||
"name": "modularload", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Dead simple page transitions and lazy loading.", | ||
@@ -5,0 +5,0 @@ "repository": "modularorg/modularload", |
@@ -42,6 +42,6 @@ <p align="center"> | ||
transitions: { | ||
article: { | ||
transitionName: { | ||
enterDelay: 450 | ||
}, | ||
contact: { | ||
transitionTwoName: { | ||
enterDelay: 600 | ||
@@ -56,7 +56,7 @@ } | ||
<nav> | ||
<a href="/contact" data-load="contact">Contact</a> | ||
<a href="/contact" data-load="transitionName">Contact</a> | ||
</nav> | ||
<div data-load-container> | ||
<h1>Hello</h1> | ||
<a href="/blog" data-load="article">Read more</a> | ||
<a href="/blog" data-load="transitionTwoName">Read more</a> | ||
</div> | ||
@@ -94,3 +94,3 @@ </body> | ||
if (transition == 'contact') { | ||
if (transition == 'transitionName') { | ||
console.log('🤙'); | ||
@@ -105,3 +105,2 @@ } | ||
| `name` | `string` | `'load'` | Data attributes name | | ||
| `page` | `string` | `'page'` | Page data attribute name | | ||
| `loadingClass` | `string` | `'is-loading'` | Class when a link is clicked | | ||
@@ -124,3 +123,2 @@ | `loadedClass` | `string` | `'is-loaded'` | Class when the new container enters | | ||
| `data-load-href` | `string` | Lazy load href attribute | | ||
| `data-page` | `string` | Page name on html element | | ||
@@ -127,0 +125,0 @@ ## Events |
@@ -5,3 +5,2 @@ export default class { | ||
name: 'load', | ||
page: 'page', | ||
loadingClass: 'is-loading', | ||
@@ -171,9 +170,13 @@ loadedClass: 'is-loaded', | ||
setAttributes(data) { | ||
const title = data.getElementsByTagName('title')[0].innerHTML; | ||
const description = data.head.querySelector('meta[name="description"]').getAttribute('content'); | ||
const page = data.querySelector('html').getAttribute('data-' + this.page); | ||
const title = data.getElementsByTagName('title')[0]; | ||
const description = data.head.querySelector('meta[name="description"]'); | ||
const datas = Object.assign({}, data.querySelector('html').dataset); | ||
document.title = title; | ||
document.head.querySelector('meta[name="description"]').setAttribute('content', description); | ||
document.querySelector('html').setAttribute('data-' + this.page, page); | ||
if (title) document.title = title.innerHTML; | ||
if (description) document.head.querySelector('meta[name="description"]').setAttribute('content', description.getAttribute('content')); | ||
if (datas) { | ||
Object.entries(datas).forEach(([key, val]) => { | ||
document.querySelector('html').setAttribute('data-' + key, val); | ||
}); | ||
} | ||
} | ||
@@ -180,0 +183,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
33015
846
3
127