Skip to content

Commit

Permalink
Merge branch '1.1-backport' into 1.1-stable
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed Jul 13, 2016
2 parents 7fa4347 + ec4b99d commit 65c137f
Show file tree
Hide file tree
Showing 43 changed files with 474 additions and 213 deletions.
7 changes: 7 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*
!README.md
!MIT-LICENSE
!dist/zepto.js
!dist/zepto.min.js
!src/*.js
src/amd_layout.js
2 changes: 1 addition & 1 deletion MIT-LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2010-2014 Thomas Fuchs
Copyright (c) 2010-2016 Thomas Fuchs
http://zeptojs.com/

Permission is hereby granted, free of charge, to any person obtaining
Expand Down
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The official site offers a download of the default distribution of Zepto. This
is good for starting out. However, at some point you might want to add some
optional modules and remove some of the default ones you don't need, to keep the
size at a minimum. That's when you need to check out Zepto's source code and use
the build commands. Alternatively you can use the web based [Zepto Builder](http://github.e-sites.nl/zeptobuilder/)
the build commands. Alternatively you can use the web based [Zepto Builder](http://github.e-sites.nl/zeptobuilder/).

You will need Node.js installed on your system.

Expand Down Expand Up @@ -196,12 +196,17 @@ This will submit a pull request to us that we can review.

### Report a bug

1. Check if the bug is already fixed in the [master branch][master] since the
last release.
1. Check if the bug is already fixed in the master branch since the last release.
2. Check [existing issues][issues]. Open a new one, including exact browser &
platform information. For better formatting of your report, see
[GitHub-flavored Markdown][mkd].

### Help! It doesn't work in browserify!

We have received complaints about not supporting popular JavaScript module loaders countless times. [Here](https://github.com/madrobby/zepto/pull/342#issuecomment-3006524) is a short explanation of our decision. A good JS loader should have a way to shim libraries which don't follow the CommonJS/AMD/UMD pattern.

[Here is an example](https://github.com/silvenon/zepto-module-demo) of shimming Zepto for browserify, allowing you to easily import only needed modules while leaving the source code untouched.

### Running tests

You will need to install [PhantomJS][]. On OS X, that's easy:
Expand All @@ -228,9 +233,8 @@ reported to the the console you started the test server in (as well as
the browser console if available).

[zeptojs.com]: http://zeptojs.com
[master]: https://github.com/madrobby/zepto/commits/master
[issues]: https://github.com/madrobby/zepto/issues
[docs]: https://github.com/madrobby/zepto/tree/gh-pages#readme
[mkd]: http://github.github.com/github-flavored-markdown/
[mkd]: https://help.github.com/articles/creating-and-highlighting-code-blocks/
[evidence.js]: https://github.com/tobie/Evidence
[phantomjs]: http://code.google.com/p/phantomjs/wiki/Installation
[phantomjs]: http://phantomjs.org/download.html
2 changes: 1 addition & 1 deletion examples/snow/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
addFlake()
el.remove() // garbage collect
}
);
)
}

while(i--) addFlake()
Expand Down
29 changes: 23 additions & 6 deletions make
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
require 'shelljs/make'
fs = require 'fs'

version = '1.1.6'
zepto_js = 'dist/zepto.js'
zepto_min = 'dist/zepto.min.js'
zepto_gz = 'dist/zepto.min.gz'
Expand All @@ -19,7 +18,7 @@ target.all = ->
target.test = ->
test_app = require './test/server'
server = test_app.listen port
exec "phantomjs --disk-cache=true test/runner.coffee 'http://localhost:#{port}/'", (code) ->
exec "phantomjs --disk-cache=true test/runner.js 'http://localhost:#{port}/'", (code) ->
server.close -> exit(code)

target[zepto_js] = ->
Expand Down Expand Up @@ -63,6 +62,18 @@ target.compress = ->
factor = fsize(zepto_js) / fsize(zepto_gz)
echo "compression factor: #{format_number(factor)}"

target.publish = ->
tag = 'v' + package_version()
if git_version() == tag
rm '-r', zepto_js
env['MODULES'] = env['NOAMD'] = ''
target.dist()
res = exec 'npm publish'
exit res.code
else
console.error 'error: latest commit should be tagged with ' + tag
exit 1

## HELPERS ##

stale = (file, source) ->
Expand All @@ -83,16 +94,22 @@ format_number = (size, precision = 1) ->
report_size = (file) ->
echo "#{file}: #{format_number(fsize(file) / 1024)} KiB"

describe_version = ->
package_version = ->
JSON.parse(cat('package.json')).version

git_version = ->
desc = exec "git --git-dir='#{root + '.git'}' describe --tags HEAD", silent: true
if desc.code is 0 then desc.output.replace(/\s+$/, '') else version
desc.output.replace(/\s+$/, '') if desc.code is 0

describe_version = ->
git_version() || package_version()

minify = (source_code) ->
uglify = require('uglify-js')
compressor = uglify.Compressor()
ast = uglify.parse(source_code)
ast.figure_out_scope()
ast.compute_char_frequency();
ast.mangle_names();
ast.compute_char_frequency()
ast.mangle_names()
ast = ast.transform(compressor)
return ast.print_to_string()
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
{
"name": "zepto"
, "version": "1.1.6"
, "main": "dist/zepto.js"
, "homepage": "http://zeptojs.com"
, "scripts": {
"test": "coffee make test"
, "dist": "coffee make dist"
, "start": "coffee test/server.coffee"
}
, "repository": "madrobby/zepto"
, "license": {
"type": "MIT"
, "url": "http://zeptojs.com/license/"
}
, "license": "MIT"
, "devDependencies": {
"uglify-js": "2.4.x"
, "express": "3.1.x"
Expand Down
17 changes: 17 additions & 0 deletions script/lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/awk -f

BEGIN { if (length(ARGV) < 2) exit 0 }

/<script/ { script=FILENAME }
/<\/script/ { script="" }

/;\s*$/ && (FILENAME !~ /.html$/ || script == FILENAME) {
printf("%s:%d: no semicolons, please\n", FILENAME, FNR)
warns++
}
/\t/ {
printf("%s:%d: use spaces instead of tabs\n", FILENAME, FNR)
warns++
}

END { if (warns) exit 1 }
8 changes: 5 additions & 3 deletions script/test
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#!/usr/bin/env bash
set -e

port=3999
test_url="http://localhost:${port}/"

export PATH=node_modules/.bin:"$PATH"

git ls-files \*.js \*.html | grep -v ^vendor/ | xargs script/lint

coffee test/server.coffee $port &
pid=$!

Expand All @@ -27,7 +31,5 @@ done
trap terminate_test_server EXIT

phantomjs --disk-cache=true \
test/runner.coffee "$test_url" "$@" \
test/runner.js "$test_url" "$@" \
2> >(grep -v "CoreText performance note" >&2)

exit $?
37 changes: 22 additions & 15 deletions src/ajax.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Zepto.js
// (c) 2010-2014 Thomas Fuchs
// (c) 2010-2016 Thomas Fuchs
// Zepto.js may be freely distributed under the MIT license.

;(function($){
var jsonpID = 0,
var jsonpID = +new Date(),
document = window.document,
key,
name,
Expand Down Expand Up @@ -79,7 +79,7 @@

var _callbackName = options.jsonpCallback,
callbackName = ($.isFunction(_callbackName) ?
_callbackName() : _callbackName) || ('jsonp' + (++jsonpID)),
_callbackName() : _callbackName) || ('Zepto' + (jsonpID++)),
script = document.createElement('script'),
originalCallback = window[callbackName],
responseData,
Expand Down Expand Up @@ -181,7 +181,7 @@
function serializeData(options) {
if (options.processData && options.data && $.type(options.data) != "string")
options.data = $.param(options.data, options.traditional)
if (options.data && (!options.type || options.type.toUpperCase() == 'GET'))
if (options.data && (!options.type || options.type.toUpperCase() == 'GET' || 'jsonp' == options.dataType))
options.url = appendQuery(options.url, options.data), options.data = undefined
}

Expand All @@ -196,6 +196,7 @@
if (!settings.crossDomain) {
urlAnchor = document.createElement('a')
urlAnchor.href = settings.url
// cleans up URL for .href (IE only), see https://github.com/madrobby/zepto/pull/1049
urlAnchor.href = urlAnchor.href
settings.crossDomain = (originAnchor.protocol + '//' + originAnchor.host) !== (urlAnchor.protocol + '//' + urlAnchor.host)
}
Expand Down Expand Up @@ -249,17 +250,23 @@
var result, error = false
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status == 304 || (xhr.status == 0 && protocol == 'file:')) {
dataType = dataType || mimeToDataType(settings.mimeType || xhr.getResponseHeader('content-type'))
result = xhr.responseText

try {
// http://perfectionkills.com/global-eval-what-are-the-options/
if (dataType == 'script') (1,eval)(result)
else if (dataType == 'xml') result = xhr.responseXML
else if (dataType == 'json') result = blankRE.test(result) ? null : $.parseJSON(result)
} catch (e) { error = e }
if (xhr.responseType == 'arraybuffer' || xhr.responseType == 'blob')
result = xhr.response
else {
result = xhr.responseText

if (error) ajaxError(error, 'parsererror', xhr, settings, deferred)
else ajaxSuccess(result, xhr, settings, deferred)
try {
// http://perfectionkills.com/global-eval-what-are-the-options/
if (dataType == 'script') (1,eval)(result)
else if (dataType == 'xml') result = xhr.responseXML
else if (dataType == 'json') result = blankRE.test(result) ? null : $.parseJSON(result)
} catch (e) { error = e }

if (error) return ajaxError(error, 'parsererror', xhr, settings, deferred)
}

ajaxSuccess(result, xhr, settings, deferred)
} else {
ajaxError(xhr.statusText || null, xhr.status ? 'error' : 'abort', xhr, settings, deferred)
}
Expand All @@ -272,11 +279,11 @@
return xhr
}

if (settings.xhrFields) for (name in settings.xhrFields) xhr[name] = settings.xhrFields[name]

var async = 'async' in settings ? settings.async : true
xhr.open(settings.type, settings.url, async, settings.username, settings.password)

if (settings.xhrFields) for (name in settings.xhrFields) xhr[name] = settings.xhrFields[name]

for (name in headers) nativeSetHeader.apply(xhr, headers[name])

if (settings.timeout > 0) abortTimeout = setTimeout(function(){
Expand Down
2 changes: 1 addition & 1 deletion src/assets.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Zepto.js
// (c) 2010-2014 Thomas Fuchs
// (c) 2010-2016 Thomas Fuchs
// Zepto.js may be freely distributed under the MIT license.

;(function($){
Expand Down
4 changes: 2 additions & 2 deletions src/callbacks.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Zepto.js
// (c) 2010-2014 Thomas Fuchs
// (c) 2010-2016 Thomas Fuchs
// Zepto.js may be freely distributed under the MIT license.

;(function($){
Expand Down Expand Up @@ -93,7 +93,7 @@
return !list
},
lock: function() {
stack = undefined;
stack = undefined
if (!memory) Callbacks.disable()
return this
},
Expand Down
2 changes: 1 addition & 1 deletion src/data.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Zepto.js
// (c) 2010-2014 Thomas Fuchs
// (c) 2010-2016 Thomas Fuchs
// Zepto.js may be freely distributed under the MIT license.

// The following code is heavily inspired by jQuery's $.fn.data()
Expand Down
2 changes: 1 addition & 1 deletion src/deferred.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Zepto.js
// (c) 2010-2014 Thomas Fuchs
// (c) 2010-2016 Thomas Fuchs
// Zepto.js may be freely distributed under the MIT license.
//
// Some code (c) 2005, 2013 jQuery Foundation, Inc. and other contributors
Expand Down
2 changes: 1 addition & 1 deletion src/detect.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Zepto.js
// (c) 2010-2014 Thomas Fuchs
// (c) 2010-2016 Thomas Fuchs
// Zepto.js may be freely distributed under the MIT license.

;(function($){
Expand Down
8 changes: 5 additions & 3 deletions src/event.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Zepto.js
// (c) 2010-2014 Thomas Fuchs
// (c) 2010-2016 Thomas Fuchs
// Zepto.js may be freely distributed under the MIT license.

;(function($){
Expand Down Expand Up @@ -119,7 +119,7 @@

var returnTrue = function(){return true},
returnFalse = function(){return false},
ignoreProperties = /^([A-Z]|returnValue$|layer[XY]$)/,
ignoreProperties = /^([A-Z]|returnValue$|layer[XY]$|webkitMovement[XY]$)/,
eventMethods = {
preventDefault: 'isDefaultPrevented',
stopImmediatePropagation: 'isImmediatePropagationStopped',
Expand All @@ -139,6 +139,8 @@
event[predicate] = returnFalse
})

event.timeStamp || (event.timeStamp = Date.now())

if (source.defaultPrevented !== undefined ? source.defaultPrevented :
'returnValue' in source ? source.returnValue === false :
source.getPreventDefault && source.getPreventDefault())
Expand Down Expand Up @@ -182,7 +184,7 @@

if (!isString(selector) && !isFunction(callback) && callback !== false)
callback = data, data = selector, selector = undefined
if (isFunction(data) || data === false)
if (callback === undefined || data === false)
callback = data, data = undefined

if (callback === false) callback = returnFalse
Expand Down
2 changes: 1 addition & 1 deletion src/form.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Zepto.js
// (c) 2010-2014 Thomas Fuchs
// (c) 2010-2016 Thomas Fuchs
// Zepto.js may be freely distributed under the MIT license.

;(function($){
Expand Down
6 changes: 3 additions & 3 deletions src/fx.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Zepto.js
// (c) 2010-2014 Thomas Fuchs
// (c) 2010-2016 Thomas Fuchs
// Zepto.js may be freely distributed under the MIT license.

;(function($, undefined){
Expand All @@ -12,10 +12,10 @@
animationName, animationDuration, animationTiming, animationDelay,
cssReset = {}

function dasherize(str) { return str.replace(/([a-z])([A-Z])/, '$1-$2').toLowerCase() }
function dasherize(str) { return str.replace(/([A-Z])/g, '-$1').toLowerCase() }
function normalizeEvent(name) { return eventPrefix ? eventPrefix + name : name.toLowerCase() }

$.each(vendors, function(vendor, event){
if (testEl.style.transform === undefined) $.each(vendors, function(vendor, event){
if (testEl.style[vendor + 'TransitionProperty'] !== undefined) {
prefix = '-' + vendor.toLowerCase() + '-'
eventPrefix = event
Expand Down
2 changes: 1 addition & 1 deletion src/fx_methods.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Zepto.js
// (c) 2010-2014 Thomas Fuchs
// (c) 2010-2016 Thomas Fuchs
// Zepto.js may be freely distributed under the MIT license.

;(function($, undefined){
Expand Down
2 changes: 1 addition & 1 deletion src/gesture.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Zepto.js
// (c) 2010-2014 Thomas Fuchs
// (c) 2010-2016 Thomas Fuchs
// Zepto.js may be freely distributed under the MIT license.

;(function($){
Expand Down
Loading

0 comments on commit 65c137f

Please sign in to comment.