Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions svg-injector.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,11 @@
}

// Copy all the data elements to the svg
var imgData = [].filter.call(el.attributes, function (at) {
return (/^data-\w[\w\-]*$/).test(at.name);
var imgData = [];
forEach.call(el.attributes, function (attribute) {
if ((/^data-\w[\w\-]*$/).test(attribute.name)) {
imgData.push(attribute);
}
});
forEach.call(imgData, function (dataAttr) {
if (dataAttr.name && dataAttr.value) {
Expand Down
4 changes: 4 additions & 0 deletions tests/prototype-compatibility/assets/svg/thumb-up.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions tests/prototype-compatibility/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>SVGInjector Test: Prototype.js Compatibility</title>
</head>
<body>
<img class="inject-me" data-src="assets/svg/thumb-up.svg">

<script src="js/prototype.js"></script>
<script src="../../svg-injector.js"></script>
<script>
// Attempting injection fails asynchronously before f5f05c010.
SVGInjector(document.querySelectorAll('img.inject-me'));
</script>
</body>
</html>
Loading