Skip to content

Commit

Permalink
Merge pull request #39 from orestbida/34-uncaught-in-promise-typeerro…
Browse files Browse the repository at this point in the history
…r-cannot-read-properties-of-undefined-reading-name

Fix uncaught exception when service div is no longer present (ref. #34)
  • Loading branch information
orestbida authored Mar 30, 2023
2 parents 851830c + e37181e commit cc610fc
Show file tree
Hide file tree
Showing 6 changed files with 443 additions and 417 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ The plugin was mainly developed to aid [**CookieConsent**](https://github.com/or
1. #### Download the [latest release](https://github.com/orestbida/iframemanager/releases/latest) or use via CDN:

```bash
https://cdn.jsdelivr.net/gh/orestbida/iframemanager@1.2.1/dist/iframemanager.js
https://cdn.jsdelivr.net/gh/orestbida/iframemanager@1.2.1/dist/iframemanager.css
https://cdn.jsdelivr.net/gh/orestbida/iframemanager@1.2.2/dist/iframemanager.js
https://cdn.jsdelivr.net/gh/orestbida/iframemanager@1.2.2/dist/iframemanager.css
```

2. #### Import script + stylesheet:
Expand Down
14 changes: 9 additions & 5 deletions demo/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ im.run({
*
* @param {HTMLDivElement} serviceDiv
*/
onReject: (serviceDiv) => {
onReject: (iframe, serviceDiv) => {
// remove: div[data-service] > div[placeholder] > div.leaflet-map
serviceDiv.lastElementChild.firstElementChild.remove();
},
Expand All @@ -120,8 +120,10 @@ im.run({
tweet && setIframe(tweet.firstChild);
},

onReject: (iframe) => {
iframe?.parentElement.remove();
onReject: async (iframe, serviceDiv, showNotice) => {
await im.childExists({parent: serviceDiv});
showNotice();
serviceDiv.querySelector('.twitter-tweet')?.remove();
},

languages : {
Expand Down Expand Up @@ -209,8 +211,10 @@ im.run({
await im.childExists({parent: div}) && setIframe(div.querySelector('iframe'));
},

onReject: (iframe) => {
iframe?.parentElement?.parentElement?.remove();
onReject: async (iframe, serviceDiv, showNotice) => {
await im.childExists({parent: serviceDiv});
showNotice();
serviceDiv.querySelector('.map')?.remove();
},

languages : {
Expand Down
4 changes: 2 additions & 2 deletions dist/iframemanager.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@orestbida/iframemanager",
"version": "1.2.1",
"version": "1.2.2",
"description": "GDPR friendly iframe manager written in vanilla js",
"main": "dist/iframemanager.js",
"files": [
Expand Down Expand Up @@ -29,10 +29,10 @@
},
"homepage": "https://github.com/orestbida/iframemanager#readme",
"devDependencies": {
"cssnano": "^5.1.14",
"cssnano": "^6.0.0",
"postcss": "^8.4.21",
"postcss-cli": "^10.1.0",
"postcss-custom-properties": "^12.1.11",
"terser": "^5.16.3"
"postcss-custom-properties": "^13.1.4",
"terser": "^5.16.8"
}
}
Loading

0 comments on commit cc610fc

Please sign in to comment.