caffeinated / bonsai

:maple_leaf: Asset management package for the Laravel 5 framework. Quite experimental.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow dev to specify extra attributes on the HTML element

erikn69 opened this issue · comments

<link rel="stylesheet" href="https://kit-pro.fontawesome.com/releases/v5.9.0/css/pro.min.css"
     crossorigin="anonymous" integrity="sha256-0YPKAwZP7Mp3ALMRVB2i8GXeEndvCq3eSl/WsAl1Ryk=" />

If loading something from a CDN or other repositories, the dev might want to pass integrity,crossorigin or other attributes. Currently we have no way of doing that. So I think we should add a new method for that, so that you can do:

PHP

Bonsai::add('https://kit-pro.fontawesome.com/releases/v5.9.0/css/pro.min.css')
    ->setAttributes([
        'integrity' => 'sha256-0YPKAwZP7Mp3ALMRVB2i8GXeEndvCq3eSl/WsAl1Ryk=',
        'crossorigin' => 'anonymous',
    ]);

.bonsai.json

"https://kit-pro.fontawesome.com/releases/v5.9.0/css/pro.min.css" : {
    "attributes" : {
        "integrity" : "sha256-0YPKAwZP7Mp3ALMRVB2i8GXeEndvCq3eSl/WsAl1Ryk=",
        "crossorigin" : "anonymous"
    }
}

script tag id, async, crossorigin, defer, integrity, nomodule, referrerpolicy
link tag id, crossorigin, href, hreflang, media, referrerpolicy, sizes, title, type

@kaidesu it's a really small not breaking change, I would be glad to do it if you wish, but I await confirmation of the PRs that are pending