fix jshint complaints in common directory

pull/1/head
ansuz 9 years ago
parent 4a05a859e6
commit a600ece5c5

@ -140,12 +140,17 @@ define([
log("No element provided!");
return null;
}
var el2,
adjusted,
initialLength;
log("Seeking to offset");
// FIXME better debugging
// console.log(el, offset);
if (!el.textContent) {
// FIXME wat
var el2 = Tree.previousNode(el, inner);
el2 = Tree.previousNode(el, inner);
log("No text content available!");
return null;
}
@ -157,19 +162,20 @@ define([
}
if (offset < 0) {
// seek backwards
var el2 = Tree.previousNode(el, inner);
el2 = Tree.previousNode(el, inner);
if (!el2) { return null; }
var adjusted = el2.textContent.length;
adjusted = el2.textContent.length;
// FIXME TypeError: el.textContent is undefined
return seekToOffset(el2, (l - 1) - el.textContent.length);
} else {
var l = el.textContent.length;
initialLength = el.textContent.length;
if (offset > l) {
var el2 = Tree.nextNode(el, inner);
el2 = Tree.nextNode(el, inner);
if (!el2) { return null; }
var adjusted = el2.textContent.length;
adjusted = el2.textContent.length;
// FIXME TypeError: el.textContent is undefined
return seekToOffset(el2, (l - 1) - el.textContent.length);
return seekToOffset(el2, (initialLength - 1) - el.textContent.length);
} else {
return {
el: el,

@ -47,7 +47,9 @@ define([], function () {
return;
}
var attributes = {};
for(var i = 0; i < el.attributes.length; i++){
var i = 0;
for(;i < el.attributes.length; i++){
var attr = el.attributes[i];
if(attr.name && attr.value){
if(attr.name == "style"){
@ -81,7 +83,9 @@ define([], function () {
// third element of the array is an array of child nodes
var children = [];
var i = 0;
// js hint complains if we use 'var' here
i = 0;
for(; i < el.childNodes.length; i++){
children.push(DOM2HyperJSON(el.childNodes[i]));
}

@ -72,11 +72,11 @@ var applyChange = function(ctx, oldval, newval) {
newvalLength: newval.length
};
if (oldval.length !== commonStart + commonEnd) {
ctx.localChange && ctx.localChange(true);
if (ctx.localChange) { ctx.localChange(true); }
ctx.remove(commonStart, oldval.length - commonStart - commonEnd);
}
if (newval.length !== commonStart + commonEnd) {
ctx.localChange && ctx.localChange(true);
if (ctx.localChange) { ctx.localChange(true); }
ctx.insert(commonStart, newval.slice(commonStart, newval.length - commonEnd));
}
};
@ -97,12 +97,13 @@ var attachTextarea = function(elem, ctx) {
// initial state will always fail the !== check in genop.
var content = {};
var newSelection;
// Replace the content of the text area with newText, and transform the
// current cursor by the specified function.
var replaceText = function(newText, transformCursor) {
if (transformCursor) {
var newSelection = [transformCursor(elem.selectionStart), transformCursor(elem.selectionEnd)];
newSelection = [transformCursor(elem.selectionStart), transformCursor(elem.selectionEnd)];
}
// Fixate the window's scroll while we set the element's value. Otherwise

Loading…
Cancel
Save