Skip to content

Commit

Permalink
[BUGFIX] Issue if no language options are set
Browse files Browse the repository at this point in the history
  • Loading branch information
deoostfrees committed Apr 10, 2024
1 parent 7861e6f commit 2dbed4a
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 20 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

- Pinch zoom gestures

## [2.5.1] - 2024-04-10

### Fixed

- Issue if no language options are set

## [2.5.0] - 2024-04-07

### Added
Expand Down
18 changes: 12 additions & 6 deletions dist/js/parvus.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Parvus
*
* @author Benjamin de Oostfrees
* @version 2.5.0
* @version 2.5.1
* @url https://github.com/deoostfrees/parvus
*
* MIT license
Expand Down Expand Up @@ -111,14 +111,17 @@ function Parvus(userOptions) {
closeButtonIcon: '<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" aria-hidden="true" focusable="false" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="1" stroke="currentColor"><path d="M18 6L6 18M6 6l12 12"/></svg>',
l10n: en
};
return {
const MERGED_OPTIONS = {
...DEFAULT_OPTIONS,
...userOptions,
l10n: {
...userOptions
};
if (userOptions && userOptions.l10n) {
MERGED_OPTIONS.l10n = {
...DEFAULT_OPTIONS.l10n,
...userOptions.l10n
}
};
};
}
return MERGED_OPTIONS;
};

/**
Expand Down Expand Up @@ -179,6 +182,9 @@ function Parvus(userOptions) {
* @param {HTMLElement} el - The element to be added
*/
const add = el => {
if (!lightbox) {
return;
}
if (!(el.tagName === 'A' && el.hasAttribute('href') || el.tagName === 'BUTTON' && el.hasAttribute('data-target'))) {
throw new Error('Use a link with the \'href\' attribute or a button with the \'data-target\' attribute. Both attributes must have a path to the image file.');
}
Expand Down
4 changes: 2 additions & 2 deletions dist/js/parvus.esm.min.js

Large diffs are not rendered by default.

18 changes: 12 additions & 6 deletions dist/js/parvus.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Parvus
*
* @author Benjamin de Oostfrees
* @version 2.5.0
* @version 2.5.1
* @url https://github.com/deoostfrees/parvus
*
* MIT license
Expand Down Expand Up @@ -117,14 +117,17 @@
closeButtonIcon: '<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" aria-hidden="true" focusable="false" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="1" stroke="currentColor"><path d="M18 6L6 18M6 6l12 12"/></svg>',
l10n: en
};
return {
const MERGED_OPTIONS = {
...DEFAULT_OPTIONS,
...userOptions,
l10n: {
...userOptions
};
if (userOptions && userOptions.l10n) {
MERGED_OPTIONS.l10n = {
...DEFAULT_OPTIONS.l10n,
...userOptions.l10n
}
};
};
}
return MERGED_OPTIONS;
};

/**
Expand Down Expand Up @@ -185,6 +188,9 @@
* @param {HTMLElement} el - The element to be added
*/
const add = el => {
if (!lightbox) {
return;
}
if (!(el.tagName === 'A' && el.hasAttribute('href') || el.tagName === 'BUTTON' && el.hasAttribute('data-target'))) {
throw new Error('Use a link with the \'href\' attribute or a button with the \'data-target\' attribute. Both attributes must have a path to the image file.');
}
Expand Down
4 changes: 2 additions & 2 deletions dist/js/parvus.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "parvus",
"type": "module",
"version": "2.5.0",
"version": "2.5.1",
"description": "An accessible, open-source image lightbox with no dependencies.",
"main": "./dist/js/parvus.js",
"module": "./dist/js/parvus.esm.js",
Expand Down
15 changes: 12 additions & 3 deletions src/js/parvus.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,19 @@ export default function Parvus (userOptions) {
l10n: en
}

return {
const MERGED_OPTIONS = {
...DEFAULT_OPTIONS,
...userOptions,
l10n: {
...userOptions
}

if (userOptions && userOptions.l10n) {
MERGED_OPTIONS.l10n = {
...DEFAULT_OPTIONS.l10n,
...userOptions.l10n
}
}

return MERGED_OPTIONS
}

/**
Expand Down Expand Up @@ -148,6 +153,10 @@ export default function Parvus (userOptions) {
* @param {HTMLElement} el - The element to be added
*/
const add = (el) => {
if (!lightbox) {
return
}

if (!((el.tagName === 'A' && el.hasAttribute('href')) || (el.tagName === 'BUTTON' && el.hasAttribute('data-target')))) {
throw new Error('Use a link with the \'href\' attribute or a button with the \'data-target\' attribute. Both attributes must have a path to the image file.')
}
Expand Down

0 comments on commit 2dbed4a

Please sign in to comment.