From 4f0112e63e78a8360c934e90e53a36ca1aaeed20 Mon Sep 17 00:00:00 2001 From: Frank Date: Wed, 14 Dec 2022 13:52:19 +0000 Subject: [PATCH 1/2] feat: oberver link tag for changes and react accordingly --- src/index.js | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/src/index.js b/src/index.js index fa12f05..dbdf773 100644 --- a/src/index.js +++ b/src/index.js @@ -25,13 +25,14 @@ let parsedCSS = []; let linkCSS = []; let themeCSS = { dark: [], light: [] }; let styleElSheet; +let parse; let linkTag = document.querySelector('link[parse], link[collection][document_id][name]'); // let linkTag = document.querySelector('link[collection][document_id][name]:not([save="false"])'); -function init() { +function init(linkTag) { if (linkTag) { - let parse = linkTag.getAttribute('parse'); + parse = linkTag.getAttribute('parse'); let styleEl = document.createElement("style"); styleEl.setAttribute('component', 'CoCreateCss'); @@ -283,7 +284,8 @@ const observerInit = () => { observe: ['childList'], target: '[class]', callback: mutation => { - initElements(mutation.addedNodes); + if (parse != 'false') + initElements(mutation.addedNodes); } }); @@ -292,11 +294,31 @@ const observerInit = () => { observe: ["attributes"], attributeName: ["class", "className"], callback: mutation => { - initElements([mutation.target]); + if (parse != 'false') + initElements([mutation.target]); } }); }; - + +observer.init({ + name: "cssParseAddedNode", + observe: ['addedNodes'], + target: 'link[parse], link[save], link[document_id]', + callback: mutation => { + init(mutation.target); + } +}); + +observer.init({ + name: "cssParseattributes", + observe: ["attributes"], + attributeName: ["parse", "save", "document_id"], + target: 'link', + callback: mutation => { + init(mutation.target); + } +}); + init(); export default {initElements}; From 4902de9e8e1decb5ff8200d6fb9c805b276291f7 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 14 Dec 2022 13:53:28 +0000 Subject: [PATCH 2/2] chore(release): 1.3.0 [skip ci] # [1.3.0](https://github.com/CoCreate-app/CoCreate-css-parser/compare/v1.2.5...v1.3.0) (2022-12-14) ### Features * oberver link tag for changes and react accordingly ([4f0112e](https://github.com/CoCreate-app/CoCreate-css-parser/commit/4f0112e63e78a8360c934e90e53a36ca1aaeed20)) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c2912e3..f084d75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# [1.3.0](https://github.com/CoCreate-app/CoCreate-css-parser/compare/v1.2.5...v1.3.0) (2022-12-14) + + +### Features + +* oberver link tag for changes and react accordingly ([4f0112e](https://github.com/CoCreate-app/CoCreate-css-parser/commit/4f0112e63e78a8360c934e90e53a36ca1aaeed20)) + ## [1.2.5](https://github.com/CoCreate-app/CoCreate-css-parser/compare/v1.2.4...v1.2.5) (2022-12-13) diff --git a/package.json b/package.json index d290e9e..f266274 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@cocreate/css-parser", - "version": "1.2.5", + "version": "1.3.0", "description": "A simple css-parser component in vanilla javascript. Easily configured using HTML5 data-attributes and/or JavaScript API.", "keywords": [ "css-parser",