StackExchange / pagedown

The Markdown editor and converter used on Stack Overflow and the other Stack Exchange sites
Other
417 stars 82 forks source link

Prompt background does not disappear after 2nd try #31

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
When clicking the image button, the wmd-prompt-background appears. If the image 
insert is canceled using callback(null); in JavaScript, then the background 
disappears. However, if the user clicks the image button again, the 
wmd-prompt-background will appear again, but whether callback(null); or 
callback("http://someurlhere.com/photo.jpg"); is used, the background will not 
disappear.

The JavaScript Console shows at this time "Uncaught TypeError: Cannot call 
method 'removeChild' of null" in Markdown.Editor.js line 1684. 

I have attached the trace that the browser's console provides. The browser 
version is Google Chrome 20.0.1132.57 m on Windows XP.

Original issue reported on code.google.com by johngti...@gmail.com on 25 Jul 2012 at 11:06

Attachments:

GoogleCodeExporter commented 8 years ago
Hmm, I can't reproduce this immediately. Are you sure the callback() call is 
asynchronous? If so, I'll need more details to reproduce this.

Original comment by b...@stackoverflow.com on 26 Jul 2012 at 4:12

ProjectPatatoe commented 3 years ago

I have this problem occurring. Firefox 86.0.1

Firefox console:

Uncaught TypeError: background.parentNode is null                 Markdown.Editor.js:1760:17
    linkEnteredCallback https://website.../Markdown.Editor.js:1760
    <anonymous> https://website.../editor.js:57
    jQuery 9
        dispatch
        handle
        add
        sa
        each
        each
        sa
        on
        b
    <anonymous> https://website.../editor.js:55
    doLinkOrImage https://website.../Markdown.Editor.js:1804
    image https://website.../Markdown.Editor.js:1502
    bindCommand https://website.../Markdown.Editor.js:1441
    doClick https://website.../Markdown.Editor.js:1399
    onclick https://website.../Markdown.Editor.js:1425
    setupButton https://website.../Markdown.Editor.js:1421
    makeButton https://website.../Markdown.Editor.js:1472
    makeSpritedButtonRow https://website.../Markdown.Editor.js:1501
    UIManager https://website.../Markdown.Editor.js:1246
    run https://website.../Markdown.Editor.js:156
    <anonymous> https://website.../editor.js:78
    <anonymous> https://website.../editor.js:80
ProjectPatatoe commented 3 years ago

Found a workaround

at Markdown.Editor.js:1760, remove background.parentNode.removeChild(background); and replace with background.remove();

This will break compatibility with IE, MDN has a polyfill available https://developer.mozilla.org/en-US/docs/Web/API/ChildNode/remove#polyfill but still does not work with IE and has the same error.