This doesn't happen often: Why is this JavaScript code only broken in Chrome? -


i've decided i've fallen in love markdown editor on stack overflow. it's fork showdown.js john fraser. want use parser on project of mine, after analyzing source, found bit messy taste.

so set modifying javascript code meet needs, namely:

  1. getting rid of global variables,
  2. combining variable declarations single var per scope,
  3. changing concatenation array joins,
  4. various other tweaks intended make minified source smaller.

i've got working beautifully, except 1 small problem: autocomplete code in command.dolist function wonky in chrome. i've tested work in internet explorer, firefox, , safari. i've isolated matter down following lines:

// item prefix - e.g. " 1. " numbered list, " - " bulleted // list. getitemprefix = function () {     var prefix;     if (isnumberedlist) {         // `s` variable string space.         prefix = [s, num, '. '].join('');         num++;     } else {         prefix = [s, bullet, s].join('');     }     return prefix; };  // fixes prefixes of other list items. getprefixeditem = function (itemtext) {     // numbering flag unset when called autoindent.     if (isnumberedlist === undefined) {         isnumberedlist = /^\s*\d/.test(itemtext);     }      // renumber/bullet list element.     // following lines commented out fix bug.     //itemtext = itemtext.replace(/^[ ]{0,3}([\*\+\-]|\d+[.])\s/gm,         // function () { return getitemprefix(); });     return itemtext; }; 

the 2 commented-out lines near end stop chrome behaving wonky, numbered lists no longer auto-increment. un-comment lines, major browsers begin working normally, except chrome. (chrome goes crazy , auto-completes list numbering , bullets, happens when trying use unordered list.)

the problem doesn't exist here on stack overflow, i'm hoping it's stupid oversight on part. (either or stack overflow has updated , fixed bug.)

you can @ fix wmd fork (line 32).


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -