better jshint compliance for common files

This commit is contained in:
ansuz 2016-02-15 15:42:08 +01:00
parent 539cc3a2fa
commit d1885fbab6
5 changed files with 17 additions and 12 deletions

View file

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

View file

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

View file

@ -149,9 +149,9 @@ define([
var doc = config.doc || null;
// 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);
// define this in case it gets called before the rest of our stuff is ready.

View file

@ -52,7 +52,9 @@ define(function () {
*/
var applyChange = function(ctx, oldval, newval) {
// 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;
while (oldval.charAt(commonStart) === newval.charAt(commonStart)) {
@ -111,7 +113,7 @@ var attachTextarea = function(elem, ctx) {
var scrollTop = elem.scrollTop;
elem.value = newText;
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
// cursor drift if the element isn't active, though usually users don't

View file

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