Skip to content
Browse files

Updated regex to deal with quotes around image references

  • Loading branch information...
1 parent 98829df commit fc95b129ac0e4683de1631f18d9263394be195fb @alexanderdickson committed May 11, 2011
Showing with 7 additions and 7 deletions.
  1. +1 −1 README.md
  2. +6 −6 jquery.waitforimages.js
View
2 README.md
@@ -1,4 +1,4 @@
-#waitForImages 1.2#
+#waitForImages 1.2.1#
Copyright (c) 2011 Alex Dickson
View
12 jquery.waitforimages.js
@@ -1,5 +1,5 @@
/*
- * waitForImages 1.2
+ * waitForImages 1.2.1
* -----------------
* Provides a callback when all images have loaded in your given selector.
* http://www.alexanderdickson.com/
@@ -48,8 +48,8 @@
'borderImage',
'borderCornerImage'
];
-
- var matchUrl = /url\((.*?)\)/g;
+
+ var matchUrl = /url\(['"]?(.*?)['"]?\)/g;
// Get all elements, as any one of them could have a background image.
obj.find('*').filter(function() {
@@ -64,15 +64,15 @@
}
$.each(hasImgProperties, function(i, property) {
- var property = element.css(property);
+ var propertyValue = element.css(property);
// If it doesn't contain this property, skip.
- if ( ! property) {
+ if ( ! propertyValue) {
return true;
}
// Get all url() of this element.
var match;
- while (match = matchUrl.exec(property)) {
+ while (match = matchUrl.exec(propertyValue)) {
allImgs.push({
src: match[1],
element: element[0]

0 comments on commit fc95b12

Please sign in to comment.
Something went wrong with that request. Please try again.