Skip to content

Commit

Permalink
Merge pull request #532 from infodusha/master
Browse files Browse the repository at this point in the history
 Printable can be exact element in html
  • Loading branch information
crabbly authored Feb 16, 2021
2 parents e42c350 + afe1153 commit c854447
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/js/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Print from './print'
export default {
print: (params, printFrame) => {
// Get the DOM printable element
const printElement = document.getElementById(params.printable)
const printElement = isHtmlElement(params.printable) ? params.printable : document.getElementById(params.printable)

// Check if the element exists
if (!printElement) {
Expand Down Expand Up @@ -63,3 +63,8 @@ function cloneElement (element, params) {

return clone
}

function isHtmlElement (printable) {
// Check if element is instance of HTMLElement or has nodeType === 1 (for elements in iframe)
return typeof printable === 'object' && printable && (printable instanceof HTMLElement || printable.nodeType === 1)
}

0 comments on commit c854447

Please sign in to comment.