Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the ability to set attributes #60

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dist/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion dist/vue-script2.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@

load(src) {
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
parent: document.head
parent: document.head,
attributes: []
};

if (!Script2.loaded[src]) {
Expand All @@ -104,6 +105,12 @@
s.src = src; // crossorigin in HTML and crossOrigin in the DOM per HTML spec
// https://html.spec.whatwg.org/multipage/embedded-content.html#dom-img-crossorigin

if(opts.attributes.length > 0)
opts.attributes.forEach(element => {
s.setAttribute(element.key,element.value)
});


if (opts.crossorigin) {
s.crossOrigin = opts.crossorigin;
} // inspiration from: https://github.com/eldargab/load-script/blob/master/index.js
Expand Down
Loading