Opened 14 years ago

Closed 12 years ago

#529 closed defect (inactive)

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 (6)

comment:1 Changed 14 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.

comment:2 Changed 14 years ago by gogo

  • Resolution set to invalid
  • Status changed from new to closed

No response. CLosing

comment:3 Changed 14 years ago by benDOTsimkinsATintsoftDOT.ch

  • Priority changed from normal to low
  • Resolution invalid deleted
  • Status changed from closed to reopened

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.

comment:4 Changed 14 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.

comment:5 Changed 14 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.

comment:6 Changed 12 years ago by ray

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