-
-
Notifications
You must be signed in to change notification settings - Fork 72
Open
Description
Hello there,
I was wondering if it was possible to return an object when onMissingElement is set to 'exception'.
Sometimes I need to broadcast cards positioned according to a predefined order to my users. However, depending on what the user is looking for, the order may change or the card I'm using to position the new element with an insertAdjacentHtml may not be present on the page. I therefore use a specific method that allows me to deal with the error and find the position of the new card if necessary.
To make things easier, I'd need to know the operation that triggered the error, in order to retrieve the html and change the selector if necessary.
Something like this in cable_ready.js would be really great
const warning = `CableReady ${name ||
''} operation failed due to missing DOM element for selector: '${
operation.selector
}'`
switch (options.onMissingElement) {
case 'ignore':
break
case 'event':
dispatch(document, 'cable-ready:missing-element', {
warning,
operation
})
break
case 'exception':
throw { name: 'MissingDOMError', operation: operation }
default:
console.warn(warning)
}
}Thanks,
Antoine
Metadata
Metadata
Assignees
Labels
No labels