Closed SchumacherFM closed 10 years ago
it looks like you might be passing some Prototype-wrapped nodes rather than vanilla DOM, so the initial parsing gets screwed up. reMarked only accepts a plain DOM structure or HTML string, so you should first convert whatever you're passing to one of those. for example, jQuery has http://api.jquery.com/html/ to get an html string out of any jQuery-wrapped structure.
As you can see in this fiddle http://jsfiddle.net/schumacherfm/97HmX/3/ I'm passing a plain HTML string to reMarked.js.
Prototype extends all vanilla JavaScript functions.
So removing prototype.js will solve this bug. But because it is Magento I cannot remove prototype.js.
i suspect there would be additional places in the lib where this would break (as well as countless other libs). constructs like this are all over the web:
for (var i in someArray) {
// whatever
}
there are a few options.
for
loopsi
is a numberArray.forEach()
and use thathasOwnProperty()
check to every loopfor (var key in p) {
if (p.hasOwnProperty(key)) {
// whatever
}
}
while i hate to cater to libs which abusively extend native prototypes, i'll probably end up switching to regular for
loops everywhere, since it's the most concise solution.
Thanks in advance for fixing :-)
Hi!
running the latest reMarked.js with prototype.js I'll get that error:
console.log in code:
My suggestion for a bugfix:
Would be nice if you can provide a fix ASAP as I want to release a new version of https://github.com/SchumacherFM/Magento-Markdown/
Thanks & Cheers!