@newlogic-digital/cookieconsent-js 0.0.3 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +4 -16
  2. package/package.json +4 -1
package/index.js CHANGED
@@ -1,25 +1,13 @@
1
+ import { appendScript } from '@newlogic-digital/utils-js'
2
+
1
3
  export const appendCookieConsent = (element, options = {}) => {
2
4
  options = {
3
- ignoreAttributeName: /(type)/,
5
+ ignoreAttributeName: /(type|data-lib-cookieconsent)/,
4
6
  delay: 0,
5
7
  ...options
6
8
  }
7
9
 
8
- const script = document.createElement('script')
9
-
10
- ;[...element.attributes].forEach(({ specified, name, value }) => {
11
- if (specified && !name.match(options.ignoreAttributeName)) {
12
- script.setAttribute(name, value)
13
- }
14
- })
15
-
16
- script.innerHTML = element.innerHTML
17
-
18
- setTimeout(() => {
19
- (element.closest('head') ? document.head : document.body).appendChild(script)
20
-
21
- element.remove()
22
- }, options.delay)
10
+ setTimeout(() => appendScript(element, options.ignoreAttributeName), options.delay)
23
11
  }
24
12
 
25
13
  export const unsetCookieConsent = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newlogic-digital/cookieconsent-js",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "author": "New Logic Studio s.r.o.",
@@ -9,6 +9,9 @@
9
9
  "eslint": "eslint '**/*.js'",
10
10
  "eslint-fix": "eslint '**/*.js' --fix"
11
11
  },
12
+ "dependencies": {
13
+ "@newlogic-digital/utils-js": "^0.0.7"
14
+ },
12
15
  "devDependencies": {
13
16
  "eslint-config-standard": "^17.1.0"
14
17
  },