Ticket #529 (closed defect: inactive)

Opened 8 years ago

Last modified 5 years ago

Needle haystack cluttering code

Reported by: bsimkinsATintsoftDOTch Owned by: gogo
Priority: low Milestone:
Component: Xinha Core Version: trunk
Severity: minor Keywords: Needle, haystack, replacements
Cc:

Description

1) A comment somewhere to explain what this stuff is would be nice 2) I would quite like to 'kill' these extra functions before saving - with specialReplacements - is this a good idea or is there a better way?

Thanks

Change History

Changed 8 years ago by gogo

I can't make head nor tail of what you are talking about. Can you try re-explaining your problem please.

Changed 8 years ago by gogo

  • status changed from new to closed
  • resolution set to invalid

No response. CLosing

Changed 7 years ago by benDOTsimkinsATintsoftDOT.ch

  • priority changed from normal to low
  • status changed from closed to reopened
  • resolution deleted

Sorry, I hadn't been back in a while. I mean this stuff:

if(!Array.prototype.contains) {

Array.prototype.contains = function(needle) {

var haystack = this; for(var i = 0; i < haystack.length; i++)

{

if(needle == haystack[i]) return true;

}

return false;

};

}

if(!Array.prototype.indexOf) {

Array.prototype.indexOf = function(needle) {

var haystack = this; for(var i = 0; i < haystack.length; i++) {

if(needle == haystack[i]) return i;

}

return null;

};

}

What's it for? I've rigged something to regexp it out when I submit, which doesn't seem to have broken anything, but I'd like to know for sure.

Changed 7 years ago by anonymous

Where are you seeing this? Actually being put into the HTML you are editing in Xinha?! If so, please provide an example of the HTML you edited triggering this behaviour.

These are methods added to the prototype of Array (the javascript Array object), they are added in htmlarea.js. You shouldn't remove them from there because it will break stuff that uses them.

Changed 7 years ago by benDOTsimkinsATintsoftDOT.ch

It's a while ago now, but it was on <P> tags that I was seeing this kind of thing:

<p contains="
function (needle) {
    var haystack = this;
    for (var i = 0; i &lt; haystack.length; i++) {
        if (needle == haystack[i]) {
            return true;
        }
    }
    return false;
}
" indexof="
function (needle) {
    var haystack = this;
    for (var i = 0; i &lt; haystack.length; i++) {
        if (needle == haystack[i]) {
            return i;
        }
    }
    return null;
}
" append="
function (a) {
    for (var i = 0; i &lt; a.length; i++) {
        this.push(a[i]);
    }
    return this;
}
">
</p>

Obviously, now I want to, I can't reproduce it... I'll remove my RegExp? hack from my code, and post here if I see the problem again.

Changed 5 years ago by ray

  • status changed from reopened to closed
  • resolution set to inactive
Note: See TracTickets for help on using tickets.