@litejs/ui
Advanced tools
Comparing version 23.4.1 to 24.0.0-rc.1
240
index.js
@@ -106,133 +106,14 @@ /*! litejs.com/MIT-LICENSE.txt */ | ||
/* global El, xhr */ | ||
!function(window, document, history, location) { | ||
var cb, base, lastRoute, iframe, tick, last | ||
var histCb, histBase, histRoute, iframe, iframeTick, iframeUrl | ||
, cleanRe = /^[#\/\!]+|[\s\/]+$/g | ||
// The JScript engine used in IE doesn't recognize vertical tabulation character | ||
// JScript engine in IE8 and below does not recognize vertical tabulation character `\v`. | ||
// http://webreflection.blogspot.com/2009/01/32-bytes-to-know-if-your-browser-is-ie.html | ||
// oldIE = "\v" == "v" | ||
// | ||
// The documentMode is an IE only property, supported in IE8+. | ||
// | ||
// Starting in Internet Explorer 9 standards mode, Internet Explorer 10 standards mode, | ||
// and win8_appname_long apps, you cannot identify the browser as Internet Explorer | ||
// by testing for the equivalence of the vertical tab (\v) and the "v". | ||
// In earlier versions, the expression "\v" === "v" returns true. | ||
// In Internet Explorer 9 standards mode, Internet Explorer 10 standards mode, | ||
// and win8_appname_long apps, the expression returns false. | ||
// The documentMode is an IE only property, supported in IE8 and up. | ||
, ie67 = !+"\v1" && (document.documentMode | 0) < 8 // jshint ignore:line | ||
function getUrl(_loc) { | ||
return ( | ||
/*** PUSH ***/ | ||
base ? location.pathname.slice(base.length) : | ||
/**/ | ||
// bug in Firefox where location.hash is decoded | ||
// bug in Safari where location.pathname is decoded | ||
// var hash = location.href.split('#')[1] || ''; | ||
// https://bugs.webkit.org/show_bug.cgi?id=30225 | ||
// https://github.com/documentcloud/backbone/pull/967 | ||
(_loc || location).href.split("#")[1] || "" | ||
).replace(cleanRe, "") | ||
} | ||
function setUrl(url, replace) { | ||
/*** PUSH ***/ | ||
if (base) { | ||
history[replace ? "replaceState" : "pushState"](null, null, base + url) | ||
} else { | ||
/**/ | ||
location[replace ? "replace" : "assign"]("#" + url) | ||
// Opening and closing the iframe tricks IE7 and earlier | ||
// to push a history entry on hash-tag change. | ||
if (iframe && getUrl() !== getUrl(iframe.location) ) { | ||
iframe.location[replace ? "replace" : iframe.document.open().close(), "assign"]("#" + url) | ||
} | ||
/*** PUSH ***/ | ||
} | ||
/**/ | ||
return checkUrl() | ||
} | ||
function checkUrl() { | ||
if (lastRoute != (lastRoute = getUrl())) { | ||
if (cb) cb(lastRoute) | ||
return true | ||
} | ||
} | ||
history.getUrl = getUrl | ||
history.setUrl = setUrl | ||
history.start = function(_cb) { | ||
cb = _cb | ||
/*** PUSH ***/ | ||
// Chrome5, Firefox4, IE10, Safari5, Opera11.50 | ||
var url | ||
, _base = document.documentElement.getElementsByTagName("base")[0] | ||
if (_base) _base = _base.href.replace(/.*:\/\/[^/]*|[^\/]*$/g, "") | ||
if (_base && !history.pushState) { | ||
url = location.pathname.slice(_base.length) | ||
if (url) { | ||
location.replace(_base + "#" + url) | ||
} | ||
} | ||
if (_base && history.pushState) { | ||
base = _base | ||
url = location.href.split("#")[1] | ||
if (url && !getUrl()) { | ||
setUrl(url, 1) | ||
} | ||
// Chrome and Safari emit a popstate event on page load, Firefox doesn't. | ||
// Firing popstate after onload is as designed. | ||
// | ||
// See the discussion on https://bugs.webkit.org/show_bug.cgi?id=41372, | ||
// https://code.google.com/p/chromium/issues/detail?id=63040 | ||
// and the change to the HTML5 spec that was made: | ||
// http://html5.org/tools/web-apps-tracker?from=5345&to=5346. | ||
window.onpopstate = checkUrl | ||
} else | ||
/**/ | ||
if ("onhashchange" in window && !ie67) { | ||
// There are onhashchange in IE7 but its not get emitted | ||
// | ||
// Basic support: | ||
// Chrome 5.0, Firefox 3.6, IE 8, Opera 10.6, Safari 5.0 | ||
window.onhashchange = checkUrl | ||
} else { | ||
if (ie67 && !iframe) { | ||
// IE<9 encounters the Mixed Content warning when the URI javascript: is used. | ||
// IE5/6 additionally encounters the Mixed Content warning when the URI about:blank is used. | ||
// src="//:" | ||
iframe = document.body.appendChild(document.createElement("<iframe tabindex=-1 style=display:none>")).contentWindow | ||
} | ||
clearInterval(tick) | ||
tick = setInterval(function(){ | ||
var cur = getUrl() | ||
if (iframe && last === cur) cur = getUrl(iframe.location) | ||
if (last !== cur) { | ||
last = cur | ||
if (iframe) setUrl(cur) | ||
else checkUrl() | ||
} | ||
}, 60) | ||
} | ||
checkUrl() | ||
} | ||
}(this, document, history, location) // jshint ignore:line | ||
/* litejs.com/MIT-LICENSE.txt */ | ||
/* global El, xhr */ | ||
!function(exports) { | ||
var fn, lastView, lastStr, lastUrl, syncResume | ||
, fn, lastView, lastStr, lastUrl, syncResume | ||
, body = document.body | ||
@@ -250,3 +131,3 @@ , isArray = Array.isArray | ||
, defaults = { | ||
base: "view/", | ||
base: "", | ||
home: "home", | ||
@@ -256,4 +137,4 @@ root: body | ||
exports.View = View | ||
exports.LiteJS = LiteJS | ||
window.View = View | ||
window.LiteJS = LiteJS | ||
@@ -497,6 +378,109 @@ | ||
}(this) // jshint ignore:line | ||
function getUrl(_loc) { | ||
return ( | ||
/*** pushState ***/ | ||
histBase ? location.pathname.slice(histBase.length) : | ||
/**/ | ||
// bug in Firefox where location.hash is decoded | ||
// bug in Safari where location.pathname is decoded | ||
// var hash = location.href.split('#')[1] || ''; | ||
// https://bugs.webkit.org/show_bug.cgi?id=30225 | ||
// https://github.com/documentcloud/backbone/pull/967 | ||
(_loc || location).href.split("#")[1] || "" | ||
).replace(cleanRe, "") | ||
} | ||
function setUrl(url, replace) { | ||
/*** pushState ***/ | ||
if (histBase) { | ||
history[replace ? "replaceState" : "pushState"](null, null, histBase + url) | ||
} else { | ||
/**/ | ||
location[replace ? "replace" : "assign"]("#" + url) | ||
// Opening and closing the iframe tricks IE7 and earlier | ||
// to push a history entry on hash-tag change. | ||
if (iframe && getUrl() !== getUrl(iframe.location) ) { | ||
iframe.location[replace ? "replace" : iframe.document.open().close(), "assign"]("#" + url) | ||
} | ||
/*** pushState ***/ | ||
} | ||
/**/ | ||
return checkUrl() | ||
} | ||
function checkUrl() { | ||
if (histRoute != (histRoute = getUrl())) { | ||
if (histCb) histCb(histRoute) | ||
return true | ||
} | ||
} | ||
history.getUrl = getUrl | ||
history.setUrl = setUrl | ||
LiteJS.start = function(cb) { | ||
histCb = cb | ||
/*** pushState ***/ | ||
// Chrome5, Firefox4, IE10, Safari5, Opera11.50 | ||
var url | ||
, _base = document.documentElement.getElementsByTagName("base")[0] | ||
if (_base) _base = _base.href.replace(/.*:\/\/[^/]*|[^\/]*$/g, "") | ||
if (_base && !history.pushState) { | ||
url = location.pathname.slice(_base.length) | ||
if (url) { | ||
location.replace(_base + "#" + url) | ||
} | ||
} | ||
if (_base && history.pushState) { | ||
histBase = _base | ||
url = location.href.split("#")[1] | ||
if (url && !getUrl()) { | ||
setUrl(url, 1) | ||
} | ||
// Chrome and Safari emit a popstate event on page load, Firefox doesn't. | ||
// Firing popstate after onload is as designed. | ||
// | ||
// See the discussion on https://bugs.webkit.org/show_bug.cgi?id=41372, | ||
// https://code.google.com/p/chromium/issues/detail?id=63040 | ||
// and the change to the HTML5 spec that was made: | ||
// http://html5.org/tools/web-apps-tracker?from=5345&to=5346. | ||
window.onpopstate = checkUrl | ||
} else | ||
/**/ | ||
if ("onhashchange" in window && !ie67) { | ||
// There are onhashchange in IE7 but its not get emitted | ||
// | ||
// Basic support: | ||
// Chrome 5.0, Firefox 3.6, IE 8, Opera 10.6, Safari 5.0 | ||
window.onhashchange = checkUrl | ||
} else { | ||
if (ie67 && !iframe) { | ||
// IE<9 encounters the Mixed Content warning when the URI javascript: is used. | ||
// IE5/6 additionally encounters the Mixed Content warning when the URI about:blank is used. | ||
// src="//:" | ||
iframe = document.body.appendChild(document.createElement("<iframe tabindex=-1 style=display:none>")).contentWindow | ||
} | ||
clearInterval(iframeTick) | ||
iframeTick = setInterval(function(){ | ||
var cur = getUrl() | ||
if (iframe && iframeUrl === cur) cur = getUrl(iframe.location) | ||
if (iframeUrl !== cur) { | ||
iframeUrl = cur | ||
if (iframe) setUrl(cur) | ||
else checkUrl() | ||
} | ||
}, 60) | ||
} | ||
xhr.load(View.$$("script[type='litejs/view']", body).map(function(el) { | ||
return el.src | ||
}), checkUrl) | ||
} | ||
}(this, document, history, location) // jshint ignore:line | ||
/* litejs.com/MIT-LICENSE.txt */ | ||
@@ -503,0 +487,0 @@ |
58
load.js
@@ -33,8 +33,9 @@ | ||
xhr._s = new Date() | ||
var loaded = {} | ||
// IE9, move setTimeout from window.prototype to window object cache, so you can override it later | ||
, setTimeout_ = (window.setTimeout = window.setTimeout) || setTimeout | ||
var loaded = xhr._l = {} | ||
, rewrite = { | ||
//!{loadRewrite} | ||
} | ||
// IE9, move setTimeout from window.prototype to window object, so you can patch it later | ||
// `|| setTimeout` is for testing | ||
, setTimeout_ = (window.setTimeout = window.setTimeout) || setTimeout | ||
/*** activex ***/ | ||
@@ -48,2 +49,3 @@ , XMLHttpRequest = +"\v1" && window.XMLHttpRequest || Function("return new ActiveXObject('Microsoft.XMLHTTP')") | ||
// THANKS: Juriy Zaytsev - Global eval [http://perfectionkills.com/global-eval-what-are-the-options/] | ||
// In case of local execution `e('eval')` returns undefined | ||
Function("e,eval", "try{return e('eval')}catch(e){}")(eval) || | ||
@@ -56,2 +58,3 @@ Function("a", "var d=document,b=d.body,s=d.createElement('script');s.text=a;b.removeChild(b.insertBefore(s,b.firstChild))") | ||
/*** reuse ***/ | ||
// XHR memory leak mitigation | ||
, xhrs = [] | ||
@@ -72,3 +75,3 @@ /**/ | ||
].join(":") | ||
) && 1 == unsentErrors.push( | ||
) && 2 > unsentErrors.push( | ||
[ +new Date() | ||
@@ -139,3 +142,3 @@ , lastError | ||
if (next !== true) xhr.onreadystatechange = function() { | ||
if (xhr.readyState == 4) { | ||
if (xhr.readyState > 3) { | ||
// From the XMLHttpRequest spec: | ||
@@ -191,33 +194,2 @@ // | ||
/*** require ***/ | ||
var modules = {} | ||
, process = window.process = { | ||
env: {} | ||
} | ||
//process.memoryUsage = function() { | ||
// return (window.performance || {}).memory || {} | ||
//} | ||
window.require = require | ||
function require(name) { | ||
var mod = modules[name] | ||
if (!mod) throw Error("Module not found: " + name) | ||
if (typeof mod == "string") { | ||
var exports = modules[name] = {} | ||
, module = { id: name, filename: name, exports: exports } | ||
Function("exports,require,module,process,global", mod).call( | ||
exports, exports, require, module, process, window | ||
) | ||
mod = modules[name] = module.exports | ||
} | ||
return mod | ||
} | ||
require.def = function(map, key) { | ||
for (key in map) modules[key] = map[key] | ||
} | ||
/**/ | ||
/*** load ***/ | ||
@@ -233,6 +205,6 @@ xhr.load = load | ||
for (; i < len; i++) if ((file = files[i]) && 2 !== loaded[file]) { | ||
for (; i < len; i++) if ((file = files[i]) && typeof loaded[file] != "object") { | ||
if (loaded[file]) { | ||
// Same file requested again | ||
;(loaded[file].x || (loaded[file].x = [])).push(cb, file, i) | ||
;(loaded[file].x || (loaded[file].x = [])).push(exec, res, i) | ||
} else { | ||
@@ -249,4 +221,4 @@ // FireFox 3 throws on `xhr.send()` without arguments | ||
function cb(err, str, file, i) { | ||
loaded[file] = 2 | ||
res[i] = err ? (onerror(err, file), "") : str | ||
loaded[file] = { h: this.getAllResponseHeaders(), b: str } | ||
res[i] = err ? (onerror(err, file), "") : loaded[file] | ||
exec() | ||
@@ -257,3 +229,3 @@ } | ||
try { | ||
;(xhr[files[pos].replace(/[^?]+\.|\?.*/g, "")] || execScript)(res[pos]) | ||
;(xhr[files[pos].replace(/[^?]+\.|\?.*/g, "")] || execScript)(res[pos].b) | ||
} catch(e) { | ||
@@ -272,4 +244,4 @@ onerror(e, files[pos]) | ||
if (next) next() | ||
if ((res = cb.x)) { | ||
for (i = 0; res[i];) res[i++](0, "", res[i++], res[i++]) | ||
if ((next = cb.x)) { | ||
for (i = 0; next[i]; ) next[i++](next[i++][next[i++]] = "") | ||
} | ||
@@ -276,0 +248,0 @@ } |
{ | ||
"name": "@litejs/ui", | ||
"version": "23.4.1", | ||
"version": "24.0.0-rc.1", | ||
"description": "UI engine for LiteJS full-stack framework", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses eval() which is a dangerous function. This prevents the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances in 1 package
146255
45
3739
1
1