-
Notifications
You must be signed in to change notification settings - Fork 20.5k
#4087 - insertAfter, insertBefore, etc do not work when destination is original element #1047
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
23f45a9
6d57472
53ec7b7
34df192
e67daf2
4ccecf9
5b9bf13
ad690f8
4ada325
3ab2634
228ab3d
2a419a7
ec72d9f
13449a9
551c2c9
4437002
5ded0c2
995837e
2eda89d
d518251
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
+102 −75 | sizzle.js | |
+1 −1 | test/index.html | |
+126 −48 | test/unit/selector.js |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
$requestArray = "REQUEST"; | ||
|
||
if ( isset( $_REQUEST["requestArray"] ) ) { | ||
$requestArray = $_REQUEST["requestArray"]; | ||
} | ||
|
||
$requestArray =& ${"_$requestArray"}; | ||
|
||
$response = array( | ||
"status" => "200", | ||
"statusText" => "", | ||
"contentType" => "text/plain", | ||
"content" => "", | ||
"callback" => "", | ||
"delay" => 0 | ||
); | ||
|
||
foreach( $response as $field => &$value ) { | ||
if ( isset( $requestArray[ $field ] ) ) { | ||
$value = $requestArray[ $field ]; | ||
} | ||
} | ||
|
||
if ( is_array( $response["content"] ) ) { | ||
$response["content"] = http_build_query( $response["content"] ); | ||
} | ||
|
||
if ( !$response["callback"] && preg_match( '/index.php\/([^\/\?&]+)/', $_SERVER["REQUEST_URI"], $match ) ) { | ||
$response["callback"] = $match[ 1 ]; | ||
} | ||
|
||
header("HTTP/1.1 $response[status] $response[statusText]"); | ||
header("Content-Type: $response[contentType]"); | ||
|
||
if ( $response["delay"] ) { | ||
sleep( $response["delay"] ); | ||
} | ||
|
||
echo $response["callback"] | ||
? "$response[callback](" . json_encode("$response[content]") . ");" | ||
: "$response[content]"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
$headers = array( | ||
|
||
"If-Modified-Since" => array( | ||
"request" => "HTTP_IF_MODIFIED_SINCE", | ||
"response" => "Last-Modified", | ||
), | ||
"If-None-Match" => array( | ||
"request" => "HTTP_IF_NONE_MATCH", | ||
"response" => "Etag", | ||
), | ||
|
||
); | ||
|
||
$header = $_REQUEST["header"]; | ||
$value = $_REQUEST["value"]; | ||
|
||
if ( $header === "If-None-Match" ) { | ||
$value = md5( $value ); | ||
} | ||
|
||
$headers = $headers[ $header ]; | ||
|
||
$requestHeader = isset( $_SERVER[ $headers["request"] ] ) ? stripslashes($_SERVER[ $headers["request"] ]) : false; | ||
if ( $requestHeader === $value ) { | ||
header("HTTP/1.0 304 Not Modified"); | ||
} else { | ||
header("$headers[response]: $value"); | ||
echo $requestHeader ? "OK: $value": "FAIL"; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
$headers = array(); | ||
|
||
foreach( $_SERVER as $key => $value ) { | ||
$key = str_replace( "_" , "-" , substr($key,0,5) == "HTTP_" ? substr($key,5) : $key ); | ||
$headers[ $key ] = $value; | ||
} | ||
|
||
foreach( explode( "," , $_GET["headers"] ) as $key ) { | ||
echo "$key: " . @$headers[ strtoupper( $key ) ] . "\n"; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
foreach( $_REQUEST as $header => $value ) { | ||
@header("$header: $value"); | ||
} |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ticket was always going to incur a performance hit, but I really like the elegance of this solution. Note that
if ( !selection || jQuery.inArray( elem, selection ) < 0 )
will probably compress a little better, but what's a De Morgan transformation or two between friends?ALSO: This changes the return value of
buildFragment
, and https://github.com/PaulBRamos/jquery/blob/e67daf2018c4d7661d4c45e3ba5ad38db9a36bf9/src/manipulation.js#L317-L336 will need some attention as a result. @dmethvin, we've been thinking about dropping the fragment cache anyway... it would probably simplify things here. I'm inclined to place the burden of proof on someone who wants to keep a ~100 byte eight-clauseif
, but I know there's a lot of history behind that preceding me.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take a look at it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hard numbers are masked by rounding, but http://jsperf.com/jquery-fragcache shows a ~7% speed improvement from the cache on IE6-7, no significant difference on IE8-9 and Chromium 20, and ~13% on Firefox 17 (not that we really care on newer browsers).
There is a benefit, but it's so modest that I'm still in favor of dropping the cache.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, thanks for that bench @gibson042! IE6 is just pitiful, but we knew that. Okay, I think we should go ahead and do this thing. It will be a good file size savings and also in-memory usage will be lower since we won't be creating frag cache entries. There's already a ticket for it at http://bugs.jquery.com/ticket/11989 and we can just pull it forward into 1.9.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PaulBRamos, do you want to take that too? Removing the fragment cache will make your job here much easier. You'll probably want to submit a separate pull request for http://bugs.jquery.com/ticket/11989 and then rebase this one after it lands.
I'm happy to do it if you prefer, but rebasing seems so much more pleasant when it's on top of your own changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/kill fragcache \o/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm on it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woah. Fragment cache gone just like that. Amazing.