better jshint compliance for common files

pull/1/head
ansuz 9 years ago
parent 539cc3a2fa
commit d1885fbab6

@ -52,7 +52,7 @@ define([], function () {
for(;i < el.attributes.length; i++){ for(;i < el.attributes.length; i++){
var attr = el.attributes[i]; var attr = el.attributes[i];
if(attr.name && attr.value){ if(attr.name && attr.value){
if(attr.name == "style"){ if(attr.name === "style"){
attributes.style = parseStyle(el); attributes.style = parseStyle(el);
} }
else{ else{

@ -6,7 +6,7 @@ define([], function () {
t = [], t = [],
rgb = [0,2,4]; rgb = [0,2,4];
while(i<n)t.push(i++); while(i<n) { t.push(i++); }
var colours = t.map(function (c, I) { var colours = t.map(function (c, I) {
return '#'+ rgb.map(function (j) { return '#'+ rgb.map(function (j) {

@ -149,9 +149,9 @@ define([
var doc = config.doc || null; var doc = config.doc || null;
// trying to deprecate onRemote, prefer loading it via the conf // trying to deprecate onRemote, prefer loading it via the conf
onRemote = config.onRemote || null; var onRemote = config.onRemote || null;
transformFunction = config.transformFunction || null; var transformFunction = config.transformFunction || null;
var socket = makeWebsocket(websocketUrl); var socket = makeWebsocket(websocketUrl);
// define this in case it gets called before the rest of our stuff is ready. // define this in case it gets called before the rest of our stuff is ready.

@ -52,7 +52,9 @@ define(function () {
*/ */
var applyChange = function(ctx, oldval, newval) { var applyChange = function(ctx, oldval, newval) {
// Strings are immutable and have reference equality. I think this test is O(1), so its worth doing. // Strings are immutable and have reference equality. I think this test is O(1), so its worth doing.
if (oldval === newval) return; if (oldval === newval) {
return;
}
var commonStart = 0; var commonStart = 0;
while (oldval.charAt(commonStart) === newval.charAt(commonStart)) { while (oldval.charAt(commonStart) === newval.charAt(commonStart)) {
@ -111,7 +113,7 @@ var attachTextarea = function(elem, ctx) {
var scrollTop = elem.scrollTop; var scrollTop = elem.scrollTop;
elem.value = newText; elem.value = newText;
content = elem.value; // Not done on one line so the browser can do newline conversion. content = elem.value; // Not done on one line so the browser can do newline conversion.
if (elem.scrollTop !== scrollTop) elem.scrollTop = scrollTop; if (elem.scrollTop !== scrollTop) { elem.scrollTop = scrollTop; }
// Setting the selection moves the cursor. We'll just have to let your // Setting the selection moves the cursor. We'll just have to let your
// cursor drift if the element isn't active, though usually users don't // cursor drift if the element isn't active, though usually users don't

@ -161,7 +161,8 @@ define([], function () {
var i = 0, success = false; var i = 0, success = false;
// FIXME can't be trusted if element is not found. // FIXME can't be trusted if element is not found.
tree.some(ancestor, function (e, index) { tree.some(ancestor, function (e, index) {
return (++i, e === el); ++i;
return e === el;
}); });
return i; return i;
}; };
@ -173,21 +174,23 @@ define([], function () {
// terminate // terminate
return true; return true;
} else { } else {
return (++i === n) ? if (++i === n) {
((el = e), true): el = e;
false; return true;
} else {
return false;
}
} }
}); });
return el; return el;
}; };
tree.contains = function (el, ancestor) { tree.contains = function (el, ancestor) {
ancestor = ancestor || inner;
return el && ancestor.contains && ancestor.contains(el); return el && ancestor.contains && ancestor.contains(el);
}; };
tree.check = function (el, ancestor) { tree.check = function (el, ancestor) {
return tree.nthFromEnd(Tree.distanceFromEnd(el, ancestor), ancestor) === el; return tree.nthFromEnd(tree.distanceFromEnd(el, ancestor), ancestor) === el;
}; };
// TODO see if we can use this // TODO see if we can use this

Loading…
Cancel
Save