Skip to content

Allow dev to specify extra attributes on the HTML element #13

Description

@erikn69
<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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions