From ddf65d28c3da978d7ca6a19dcce2cf2b4ee14a8d Mon Sep 17 00:00:00 2001 From: Sandeep Gosavi Date: Wed, 30 Jun 2021 23:08:10 +0530 Subject: [PATCH] Update html.js It is not always possible to send id of the html. In such cases we can use data-printid attribute. --- src/js/html.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/js/html.js b/src/js/html.js index 5e8b96d..41ecc44 100644 --- a/src/js/html.js +++ b/src/js/html.js @@ -5,7 +5,12 @@ export default { print: (params, printFrame) => { // Get the DOM printable element const printElement = isHtmlElement(params.printable) ? params.printable : document.getElementById(params.printable) - + + // check if data-printid for the element exist + if (!printElement) { + printElement = document.querySelector('[data-printid="'+ params.printable +'"]'); + } + // Check if the element exists if (!printElement) { window.console.error('Invalid HTML element id: ' + params.printable)