Skip to content

Commit

Permalink
drop normalizeSpace
Browse files Browse the repository at this point in the history
  • Loading branch information
fizx committed Dec 30, 2009
1 parent 87eeb9c commit cf1cc05
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 22 deletions.
18 changes: 2 additions & 16 deletions jquery.parsley.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,6 @@ StringNodeList.prototype.toString = function() {
return buffer + "]>";
}

/**
* Trims and replaces arbitrary whitespace with single spaces.
*/
StringNodeList.prototype.normalizeSpace = function() {
jQuery.each(this, function() {
this.string = pQuery.normalizeSpace(this.string);
});
return this;
}

/**
* Creates an array of strings that mirrors this StringNodeList.
*/
Expand All @@ -77,7 +67,7 @@ StringNodeList.prototype.simple = function() {
*
* The following shortcut arguments are also available:
* - extract()
* => function(node) { return pQuery.normalizeSpace(jQuery(node).text()); }
* => function(node) { return jQuery(node).text(); }
* - extract("@foo")
* => function(node) { return jQuery(node).attr("foo"); }
* - extract(/regex/)
Expand All @@ -86,7 +76,7 @@ StringNodeList.prototype.simple = function() {
jQuery.fn.extract = function(func) {
if(!func){
func = function(node) {
return pQuery.normalizeSpace(jQuery(node).text());
return jQuery(node).text();
};
}

Expand Down Expand Up @@ -180,10 +170,6 @@ pQuery.group = function(parselet) {
});
}

pQuery.normalizeSpace = function(string) {
return string.replace(/\s+/g, ' ').replace(/^\s+/m, '').replace(/\s+$/m, '');
}

pQuery.extract = function(parselet) {
jQuery.each(parselet, function(key, value) {
if(typeof(value) == "array") {
Expand Down
8 changes: 2 additions & 6 deletions tests.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@
return max;
}).simple(), [25, 10]);
});

test("trailing space normalization", function() {
same($(".message").extract().normalizeSpace().simple(), ["Merry christmas!", "Happy new year!"]);
});


test("extract", function(){
var parselet = {
page: location.href.split("/").pop,
Expand Down Expand Up @@ -88,7 +84,7 @@ <h1>Test dom</h1>
<ul>
<li>
<span class="date">12/25/09</span>
<span class="message" id="b">Merry christmas! </span>
<span class="message" id="b">Merry christmas!</span>
</li>
<li>
<span class="date">01/01/10</span>
Expand Down

0 comments on commit cf1cc05

Please sign in to comment.