last day (21 days later) » 

9:16 PM
531
A: Creating a new DOM element from an HTML string using built-in DOM methods or prototype

Crescent FreshGenerally the following cross-browser trick is what all the libraries do to get DOM elements from an HTML string (with some extra work for IE for <td>s, <tr>s, <thead>s, <select>s and more): var s = '<li>text</li>'; // HTML string var div = document.createElement('div'); div.innerHTML = s; var ...

 
@mikemaccana, your edit removed multiple bits of information from the question: the solution with Prototype; how to do this for a single vs multiple nodes; that this solution is (or rather was) used in popular libraries; and that supporting old IE versions requires some additional work. Even leaving aside that this answer is (and always was) flawed, and that I'd recommend modern readers use mine instead, I don't see any good reason for deleting all of that info, and have accordingly rolled back your edit.
 
@MarkAmery My edit fixed the minified code, added a wrapper functions, removed the outdated information regarding versions of IE no longer in popular use, and removed the prototype.js info, as prototype is no longer popular. Thanks for letting me know you rolled it back. I'll make the same fixes again and leave in the information about ancient versions of IE for (both) developers who love IE8 and (all three) developers who love prototype.js in 2018,, not for the benefit of readers, but simply to keep you happy.
 
@mikemaccana "Minified code" seems like a slightly hyperbolic way of saying "most variables have full English names, but there's also a string named s", but sure - I've got no objection to renaming that to htmlString.
 
@MarkAmery hyperbolic would be insisting web development answers in 2018 must still include info for IE8 and prototype.js users.
 
@mikemaccana I've rolled back your edit again, for several reasons: the function at the top was broken in two ways (missing trim() and a variable name error), there were a bunch of English errors, the snark about old browsers and libraries was entirely gratuitous, it invalidated a bunch of comments, and more fundamentally it transformed the post into a totally different answer than the one that Crescent Fresh originally posted; I don't think that hijacking an accepted answer to post an entirely different solution is a legit use of editing powers. If you disagree, we can take it to Meta.
 
9:16 PM
Mark: I added '.trim()` to the answer to handle TemplateStrings. Indeed, I forgot to add it to the second answer: perhaps you should have suggested that as a constructive way of giving feedback rather than revert the answer to it's nine year old state. I don't think there was any snark, but the comments only existed because you personally insisted IE8 and prototype.js be left in an answer in 2018. I've undone the vandalism: if you believe that maintaining old answers should be forbidden on StackOverflow, take it to meta yourself.
 
@mikemaccana Seriously, your response to a rollback in which I @-notified you with a detailed explanation of my reasoning and invited further discussion is to reapply your edit without notifying me? I've mod-flagged. And yes, I think that on a question tagged with prototypejs and which explicitly asks about answers using Prototype, the prototype solution shouldn't be scrubbed from the accepted answer. "Maintaining" an answer and replacing it wholesale with a different answer via an edit are not the same thing.
@mikemaccana Note also that your template-based approach doesn't return an Element at all, but a document fragment, so was misleadingly named. As an aside unrelated to the editing dispute: I notice that you used cloneNode in your template-based solution. What was the motivation for that? Is there some benefit to using that I'm missing, such that I ought to add it to my answer?
@mikemaccana As a final note - according to the comments (though I haven't confirmed) the "extra work" for the div-based solution is needed for IE versions at least as late as IE 10 - not just "IE 8 and earlier" as your edit claimed. My frustration doesn't come from me being totally dogmatic about radical edits - I'm not, and I occasionally make them myself, cautiously, while trying my hardest to make damn sure that I do no harm. Rather, I'm pissed off because on every pass here your edits have made a mess, either by removing information of possible value or by introducing errors.
@mikemaccana Hmm. I've cooled my head and retracted my mod flag, because I think we can still probably find a final form for this answer that will satisfy us both. I sympathise with wanting the top answer on the Q to not mislead people; I just don't think that basically duplicating my solution into there is the right way, especially when this post still has upsides over mine (compatibility with older browsers). Unless you object and would rather take this to Meta/mods, after work I'll tweak the answer to note explicitly that (unlike some other approaches) this won't work for ... (TBC)
@mikemaccana (continued) ... some elements, like tds, but that it has the advantage of decent support for old browsers. I'll keep all the information - about this (once) being a technique used in library internals, about the Prototype solution, and about the extra work needed to support IE. And then new readers can see up front that this has downsides, and if they want a template-based solution, scroll down to mine. Does that seem reasonable to you?
 
Mark: I've already kept the info about prototype, and old IE, and tds, so I don't understand what work you would be doing by modifying the answer again. I updated the answer with the template as that should be preferable, including a link to the official docs with proper link text (unlike your own answer) as that's a reasonable update to a question whose answer has changed. I suggest that the issue is not updating old answers with new info, but a personal one as you have one of the other answers, albeit with less information. So short answer: no. Please don't remove any further work.
Mark: I see you've ignored your own promise not to vandalise further unless asked. I've reverted the changes again. Please stop vandalising answers and file a meta issue if you dislike updates to decade old answers.
 
@mikemaccana I've reverted, again. It's not "vandalism" - your revision contains outright errors that I've explicitly pointed out to you over several comments and you went ahead and reintroduced them. I've made clear to you that my issue is not just with major modifications being made to old answers; it's also with the fact that your changes are outright wrong and that by fixing them I'd effectively just be copying my own answer into Crescent Fresh's. If we were going to take this to Meta, the starting point ought to be us having an edit to discuss that doesn't leave the post crap.
 
Moderator note: when a post is rolled back and you can't agree as to what should happen with a post, do not continue to edit war. This should have been taken to Meta ages ago.
6 messages moved to Trash
 
@MartijnPieters What's to discuss on Meta? We don't even have a stable candidate for a revision to swap to, and @mikemaccana is deliberately reintroducing outright errors that I've already pointed out just to fuck with me. What exactly am I meant to ask?
If there were still any good-faith attempt at improving the post going on here, I'd be more than happy to take it to Meta and argue my case there... but there's nothing to argue over.
Scratch that, I'll post on Meta.
Gimme an hour... :(
 
9:47 PM
@MartijnPieters, what does it mean for messages to be moved to Trash? I'm afraid I'm fairly unfamiliar with Chat. Is this room still an accurate record of the conversation between me and mikemaccana?
 
@MarkAmery: I'd have liked you to flag for mod attention earlier. At or before rollback #2.
The messages have not been moved to trash, they have been moved to this chatroom. Chatrooms are far better suited for extended discussion.
 
I did, then retracted because at that point mike was still acting in good faith and I reckoned we could reach an agreeable compromise without invoking the "exception handlers"
 
The same remark absolutely applies to @mikemaccana here.
 
Turned out differently, unfortunately
re: trash, I see "6 messages moved to Trash" below your moderator note - was wondering what that meant
 
@mikemaccana: basically, when you edit someone else's answer, and someone objects, stop, and try to find a consensus. If you can't, bring it to Meta. Do not push through! It doesn't matter here if you or Mark is right, you need to bring in community concensus if you can't see eye to eye with the person that challenged you.
 
9:51 PM
Hey @CrescentFresh, I see you've joined. Erm, sorry about all the notifications. :P
 
@MarkAmery right, I only have the option to move or copy all comments on a post to a chatroom. That's me cleaning up the irrelevant comments that predated this spat.
 
aha
 
10:45 PM
FWIW, i honestly don't know what the official (meta) stance on accepted answers that are wholly irrelevant today when there exists other, recent answers that supersede it. Should the accepted answer be completely replaced with the contents/spirit/intent of another, better answerer's answer, simply "because visibility"? Maybe the community should be able to pick the new "de facto" accepted answer? I'm here because I'm curious about the outcome.
 
> wholly irrelevant today

FWIW I dispute this characterisation
your answer provides better support for old browsers than mine
it is not yet obsolete
> Maybe the community should be able to pick the new "de facto" accepted answer

I'm of the view (as is moderator Brad Larson, IIRC) that acceptance should be completely ignored in ordering answers, and only votes should matter. Unfortunately that's not the current way of things, and it wouldn't change the ordering here anyway
 
I have a number of answers that were marked as accepted but I don't have the time to go through them and delete them (let alone update them!), nor do I think deleting them serves the community very well. But they are basically historical artifacts that should not be the accepted approach any longer.
 
One thing you can do is comment on the question to suggest that the asker change the accepted answer to whatever one you favour. I sometimes do that to promote my own answers to old questions, when I think that they're wholly superior to the old accepted answer
I refrained from doing so here because it's not that clear cut - your answer still has its place
 
The spirit of Mike's edits were to replace the accepted answer with information from other answers and/or other known sources in order to make it better and more relevant to the community today. He did that as opposed to providing his own answer. I don't know which approach is right. (Disregarding the content of his edits).
 
I do think that editing your answer to basically contain the spirit of my answer would be wrong, and am arguing that in the Meta post I'm currently writing
 
10:52 PM
> One thing you can do is comment on the question to suggest that the asker change the accepted answer to whatever one you favour.
I would love if the original posters of some of these questions were still around to answer to such a comment.
 
Yeah, often a problem. In this case, the asker is :)
 
Thanks for taking it to Meta.
 
 
1 hour later…
11:57 PM
Meta thread: https://meta.stackoverflow.com/questions/361836/help-adjudicate-a-complicated-edit-war-on-a-question-about-parsing-html-in-javas

@mikemaccana FYI
 

  last day (21 days later) »