Permalink
Browse files

Merge remote-tracking branch 'upstream/master'

  • Loading branch information...
2 parents bdca8c8 + 433df87 commit 669b956e343a5a28576f33e7a5ff0d0c968579e2 @lvivski committed Mar 14, 2012
Showing with 57 additions and 6 deletions.
  1. +2 −0 .gitignore
  2. +14 −4 README.md
  3. +3 −2 src/ajax.js
  4. +22 −0 test/ajax.html
  5. +16 −0 test/fixtures/ajax_load_selector_javascript.html
View
@@ -5,3 +5,5 @@ dist/zepto.js
pkg
*.swp
docs/*
+.jhw-cache
+.rbenv-version
View
@@ -388,15 +388,25 @@ Checklist for submitting patches:
* Run `rake whitespace` to clean up whitespace in code & tests
* Use Github's pull request system to submit patches
+# Running tests
+
If you submit patches, please include tests.
-Also, Zepto.js contains some non-jQuery extensions, that are geared towards mobile devices.
+Zepto tests are written using Evidence.js and can be found
+in the `test` folder. See https://github.com/tobie/Evidence for more info on Evidence.
+
+Simply add your tests (see existing tests as templates) and then view the HTML file in a browser).
+For detailed results, see the JavaScript console in your browser.
-Visit http://zeptojs.com/
+_There's experimental support for automatically running tests on the command line and integrating them
+with a continuous integration server, using the `jasmine-headless-webkit` Rubygem, which in turnrequires
+Qt to be installed and a `CI` environment variable set (you can then run `bundle` to install the
+required dependencies and run `rake test` to run the tests). (This is not for the faint of heart and
+right now is experimental only, so don't blame us if you can't get it to work!)_
-Join Zepto.js Convore group https://convore.com/zeptojs/, #zepto on irc.freenode.net and stay updated on http://twitter.com/zeptojs
+IRC channel: #zepto on irc.freenode.net stay updated on http://twitter.com/zeptojs
-Have fun!
+Remember to have fun!
# License
View
@@ -7,7 +7,8 @@
isObject = $.isObject,
document = window.document,
key,
- name;
+ name,
+ rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi;
// trigger a custom event and return false if it was cancelled
function triggerAndReturn(context, eventName, data) {
@@ -380,7 +381,7 @@
if (parts.length > 1) url = parts[0], selector = parts[1];
$.get(url, function(response){
self.html(selector ?
- $(document.createElement('div')).html(response).find(selector).html()
+ $(document.createElement('div')).html(response.replace(rscript, "")).find(selector).html()
: response);
success && success.call(self);
});
View
@@ -152,6 +152,28 @@
});
},
+ testAjaxLoadWithJavaScript: function (t) {
+ var testEl = $('#ajax_load');
+ t.pause();
+ window.testValue = 0;
+ testEl.load('fixtures/ajax_load_selector_javascript.html', function() {
+ deferredResume(t, function () {
+ this.assertEqual(window.testValue, 1);
+ });
+ });
+ },
+
+ testAjaxLoadWithSelectorAndJavaScript: function (t) {
+ var testEl = $('#ajax_load');
+ t.pause();
+ window.testValue = 0;
+ testEl.load('fixtures/ajax_load_selector_javascript.html #ajax_load_test_div', function() {
+ deferredResume(t, function () {
+ this.assertEqual(window.testValue, 0);
+ });
+ });
+ },
+
testAjaxWithContext: function(t) {
t.pause();
var body = $('body');
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>testAjaxLoad</title>
+</head>
+<body>
+<div id="ajax_load_test_div">ajax load with selector</div>
+<div>
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
+</div>
+<script>
+ window.testValue = 1;
+</script>
+</body>
+</html>

0 comments on commit 669b956

Please sign in to comment.