Skip to content

Commit

Permalink
fix(content): error when using the trigger block
Browse files Browse the repository at this point in the history
  • Loading branch information
Kholid060 committed Nov 3, 2021
1 parent af9b16c commit 0e9c745
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"pre-commit": "npx lint-staged"
},
"lint-staged": {
"*.{js,ts,vue}": "eslint --cache --fix"
"*.{js,ts,vue}": "eslint --fix"
},
"dependencies": {
"@medv/finder": "^2.1.0",
Expand Down
8 changes: 5 additions & 3 deletions src/content/blocks-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function isElementUnique(element, { data, id }) {
return true;
}
function handleElement({ data, id }, callback) {
if (!data.selector) return null;
if (!data || !data.selector) return null;

const element = data.multiple
? document.querySelectorAll(data.selector)
Expand Down Expand Up @@ -137,9 +137,11 @@ export function forms(block) {
});
}

export function triggerEvent({ data }) {
export function triggerEvent(block) {
return new Promise((resolve) => {
handleElement(data, (element) => {
const { data } = block;

handleElement(block, (element) => {
simulateEvent(element, data.eventName, data.eventParams);
});

Expand Down

0 comments on commit 0e9c745

Please sign in to comment.