lavary / laravel-menu

A quick way to create menus in Laravel
MIT License
1.16k stars 233 forks source link

escaping of attrs #243

Open ToeiRei opened 5 years ago

ToeiRei commented 5 years ago

I'm currently trying to add a menu to log out - laravel auth Package style:

$menu->add( __('Logout'), route('logout')) 
                 ->attr(['class' => 'nav-item'])
                 ->prepend('<i class="fas fa-sign-out-alt"></i><span>')
                 ->append('</span>')
                 ->link->attr(['class' => 'nav-link', 'onClick' => 'event.preventDefault(); document.getElementById(\'logout-form\').submit();']);

So far no big deal until I noticed the ' being escaped, breaking code.

dustingraham commented 5 years ago

Howdy, I don't have time to dig into this and look at how it's working.

One quick option that comes to mind is you could add a class or id, and then bind the on-click in javascript after page load using the class or id, instead of adding it inline.

ToeiRei commented 5 years ago

It took me quite a while to figure out why things were broken - the workaround via binding an id is already in place. Just thought I'd report that behavior as I am not sure if it's a bug or feature and obviously not me to decide.

dustingraham commented 5 years ago

Great thanks, I'll leave this open for review.