unprint 0.11.1 → 0.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/app.js +21 -11
- package/tests/index.html +2 -1
package/package.json
CHANGED
package/src/app.js
CHANGED
|
@@ -483,12 +483,10 @@ function querySourceSets(context, selector, attr = 'srcset', customOptions = {})
|
|
|
483
483
|
return sourceSets.map((sourceSet) => extractSourceSet(sourceSet, customOptions));
|
|
484
484
|
}
|
|
485
485
|
|
|
486
|
-
/*
|
|
487
486
|
function removeStyleFunctionSpaces(el) {
|
|
488
487
|
// jsdom appears to have a bug where it ignores inline CSS attributes set to a function() containing spaces, e.g. url( image.png )
|
|
489
488
|
el.setAttribute('style', el.getAttribute('style').replace(/\(\s+(.*)\s+\)/g, (match, cssArgs) => `(${cssArgs})`));
|
|
490
489
|
}
|
|
491
|
-
*/
|
|
492
490
|
|
|
493
491
|
function queryStyle(context, selector, customOptions) {
|
|
494
492
|
const options = {
|
|
@@ -496,12 +494,16 @@ function queryStyle(context, selector, customOptions) {
|
|
|
496
494
|
attribute: 'style',
|
|
497
495
|
};
|
|
498
496
|
|
|
499
|
-
const
|
|
497
|
+
const element = queryElement(context, selector, options);
|
|
500
498
|
|
|
501
|
-
if (
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
499
|
+
if (element) {
|
|
500
|
+
removeStyleFunctionSpaces(element);
|
|
501
|
+
|
|
502
|
+
if (element.style) {
|
|
503
|
+
return options.styleAttribute
|
|
504
|
+
? element.style.getPropertyValue(options.styleAttribute)
|
|
505
|
+
: element.style._values;
|
|
506
|
+
}
|
|
505
507
|
}
|
|
506
508
|
|
|
507
509
|
return null;
|
|
@@ -513,11 +515,19 @@ function queryStyles(context, selector, customOptions) {
|
|
|
513
515
|
attribute: 'style',
|
|
514
516
|
};
|
|
515
517
|
|
|
516
|
-
const elStyles =
|
|
517
|
-
|
|
518
|
-
|
|
518
|
+
const elStyles = queryElements(context, selector, options).map((element) => {
|
|
519
|
+
removeStyleFunctionSpaces(element);
|
|
520
|
+
|
|
521
|
+
if (element.style) {
|
|
522
|
+
return options.styleAttribute
|
|
523
|
+
? element.style.getPropertyValue(options.styleAttribute)
|
|
524
|
+
: element.style._values;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
return null;
|
|
528
|
+
});
|
|
519
529
|
|
|
520
|
-
return elStyles;
|
|
530
|
+
return elStyles.filter(Boolean);
|
|
521
531
|
}
|
|
522
532
|
|
|
523
533
|
function queryVideo(context, selector = 'source', customOptions) {
|
package/tests/index.html
CHANGED
|
@@ -42,7 +42,8 @@
|
|
|
42
42
|
<img class="srcset" srcset="https://i.redd.it/e91oo4ueyeb71.jpg 240w, https://i.redd.it/vn9h981hlx281.png 480w, https://i.redd.it/e91oo4ueyeb71.jpg 640w">
|
|
43
43
|
<img class="srcset" srcset="https://i.redd.it/e91oo4ueyeb71.jpg 240w, https://i.redd.it/vn9h981hlx281.png 480w, https://i.redd.it/e91oo4ueyeb71.jpg 640w">
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
<!-- deliberate space in url( ) to test JSDOM's quirky handling of this -->
|
|
46
|
+
<div class="style" style="background-image: url( https://i.imgur.com/eDQmLys.jpg ); color: red;"></div>
|
|
46
47
|
<div class="style" style="margin: 1rem; color: blue;"></div>
|
|
47
48
|
|
|
48
49
|
<video id="video" poster="https://i.imgur.com/eDQmLys.jpg"><source src="https://i.imgur.com/eDQmLys.mp4"></video>
|