Skip to content
This repository was archived by the owner on Sep 6, 2022. It is now read-only.

Commit ad36a2b

Browse files
Christophe de JongeChristophe de Jonge
authored andcommitted
Skip non-img nodes when using options.elements
Prevent processing when `options.elements` contains non-`img` nodes.
1 parent 2978c4a commit ad36a2b

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

dist/picturefill.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,11 @@ window.matchMedia || (window.matchMedia = function() {
503503
firstMatch = undefined;
504504
candidates = undefined;
505505

506+
// immediately skip non-`img` nodes
507+
if ( element.nodeName.toUpperCase() !== "IMG" ) {
508+
continue;
509+
}
510+
506511
// expando for caching data on the img
507512
if ( !element[ pf.ns ] ) {
508513
element[ pf.ns ] = {};

dist/picturefill.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/picturefill.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,11 @@
454454
firstMatch = undefined;
455455
candidates = undefined;
456456

457+
// immediately skip non-`img` nodes
458+
if ( element.nodeName.toUpperCase() !== "IMG" ) {
459+
continue;
460+
}
461+
457462
// expando for caching data on the img
458463
if ( !element[ pf.ns ] ) {
459464
element[ pf.ns ] = {};

0 commit comments

Comments
 (0)