Skip to content

Commit

Permalink
Big fix: .htc behavior urls incorrectly resolved against CSS url. Fix…
Browse files Browse the repository at this point in the history
…es CSS3PIE issue.

Test Added.
  • Loading branch information
keithclark committed Jun 21, 2011
1 parent b2bca1a commit 89bc655
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
3 changes: 2 additions & 1 deletion changelog.txt
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ selectivizr - change log
Current Build
-------------

* BUG - resolveUrl() fails to resolve protocol relative urls
* BUG - behaviors (.htc files) are now ignored when processing urls. Fixes "CSS3PIE" issue
* BUG - resolveUrl() fails to resolve protocol relative urls. Fixes "AddThis" issue
* NEW - expose selectiviz'd cssText through styleSheet object via 'rawCssText' expando property
* BUG - incorrect parsing of @media blocks (fixes respondJS compatibility issue)
* BUG - resolveUrl() incorrectly fails external assets urls for violating the same origin policy
Expand Down
6 changes: 3 additions & 3 deletions selectivizr.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ References:
// Stylesheet parsing regexp's
var RE_COMMENT = /(\/\*[^*]*\*+([^\/][^*]*\*+)*\/)\s*?/g;
var RE_IMPORT = /@import\s*(?:(?:(?:url\(\s*(['"]?)(.*)\1)\s*\))|(?:(['"])(.*)\3))\s*([^;]*);/g;
var RE_ASSET_URL = /\burl\(\s*(["']?)(?!data:)([^"')]+)\1\s*\)/g;
var RE_ASSET_URL = /(behavior\s*?:\s*)?\burl\(\s*(["']?)(?!data:)([^"')]+)\2\s*\)/g;
var RE_PSEUDO_STRUCTURAL = /^:(empty|(first|last|only|nth(-last)?)-(child|of-type))$/;
var RE_PSEUDO_ELEMENTS = /:(:first-(?:line|letter))/g;
var RE_SELECTOR_GROUP = /((?:^|(?:\s*})+)(?:\s*@media[^{]+{)?)\s*([^\{]*?[\[:][^{]+)/g;
Expand Down Expand Up @@ -446,9 +446,9 @@ References:
var cssText = parseStyleSheet(resolveUrl(importUrl || importUrl2, url));
return (media) ? "@media " + media + " {" + cssText + "}" : cssText;
}).
replace(RE_ASSET_URL, function( match, quoteChar, assetUrl ) {
replace(RE_ASSET_URL, function( match, isBehavior, quoteChar, assetUrl ) {
quoteChar = quoteChar || EMPTY_STRING;
return " url(" + quoteChar + resolveUrl(assetUrl, url, true) + quoteChar + ") ";
return isBehavior ? match : " url(" + quoteChar + resolveUrl(assetUrl, url, true) + quoteChar + ") ";
});
}
return EMPTY_STRING;
Expand Down
3 changes: 3 additions & 0 deletions tests/master/css/master.css
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ body {
background: #c00 url("https://github.com/keithclark/selectivizr/raw/master/tests/master/css/nested/test.png");
}

#url-htc {
behavior: url(htc/test.htc);
}

/* pseudo-class tests
------------------------------------------------------------------------------------ */
Expand Down
6 changes: 6 additions & 0 deletions tests/master/htc/test.htc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<public:attach event="ondocumentready" onevent="test()" />
<script type="text/javascript">
function test() {
this.style.background="#0c0"
}
</script>
4 changes: 4 additions & 0 deletions tests/master/index.html
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ <h3>url syntax tests</h3>
<td>background: url("http://domain/test.png")</td>
<td>Testing css property referring to an asset on an external domain</td>
</tr>
<tr id="url-htc">
<td>background: url("js/test.htc")</td>
<td>Testing behavior url resolves relative to the document url</td>
</tr>
</table>

<h3>iframe tests</h3>
Expand Down

0 comments on commit 89bc655

Please sign in to comment.