Skip to content

Commit

Permalink
update collectStyles match, skip empty properties
Browse files Browse the repository at this point in the history
  • Loading branch information
crabbly committed Jun 5, 2018
1 parent 6568e37 commit 6135a43
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "print-js",
"homepage": "http://printjs.crabbly.com",
"description": "A tiny javascript library to help printing from the web.",
"version": "1.0.45",
"version": "1.0.46",
"main": "dist/print.js",
"repository": "https://github.com/crabbly/Print.js",
"license": "MIT",
Expand Down
8 changes: 3 additions & 5 deletions src/js/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ export function capitalizePrint (string) {
export function collectStyles (element, params) {
let win = document.defaultView || window

let styles = win.getComputedStyle

// String variable to hold styling for each element
let elementStyle = ''

Expand All @@ -22,12 +20,12 @@ export function collectStyles (element, params) {
if (params.honorColor) params.targetStyles.push('color')

// Loop over computed styles
styles = win.getComputedStyle(element, '')
let styles = win.getComputedStyle(element, '')

Object.keys(styles).map(key => {
// Check if style should be processed
if (params.targetStyles === ['*'] || params.targetStyle.indexOf(styles[key]) !== -1 || targetStylesMatch(params.targetStyles, styles[key])) {
elementStyle += styles[key] + ':' + styles.getPropertyValue(styles[key]) + ';'
if (params.targetStyles.indexOf('*') !== -1 || params.targetStyle.indexOf(styles[key]) !== -1 || targetStylesMatch(params.targetStyles, styles[key])) {
if (styles.getPropertyValue(styles[key])) elementStyle += styles[key] + ':' + styles.getPropertyValue(styles[key]) + ';'
}
})

Expand Down

0 comments on commit 6135a43

Please sign in to comment.