jakiestfu / Medium.js

A tiny JavaScript library for making contenteditable beautiful (Like Medium's editor)
http://jakiestfu.github.io/Medium.js/
4.39k stars 403 forks source link

2.0 alpha - undefined on invoke element #142

Open bearded-avenger opened 9 years ago

bearded-avenger commented 9 years ago

Just a heads up, invoke element is returning an undefined in Chrome. Possibly the same as https://github.com/jakiestfu/Medium.js/issues/131

http://cl.ly/image/1S0J1q1o2b2w

        document.getElementById('make-my-shit-bold').onmousedown = function() {
            article.highlight();
            articleMedium.invokeElement('b');
            return false;
        };

This is now returning Uncaught TypeError: Cannot read property 'remove' of undefined in Chrome.

optimus-code commented 9 years ago

I encountered this as well, in my instance attributes was not specified because i did not need to set any. You can place a blank {} in attributes or go into Medium.js and change:

Line 557 - remove = attributes.remove || [];

to

Line 557 - remove = ( attributes ? attributes.remove || [] : [] );