postman: add second argument for custom props

This commit is contained in:
0x1eef 2023-06-30 23:28:48 -03:00
parent fe108563fa
commit d186dce484
2 changed files with 10 additions and 8 deletions

View file

@ -6,6 +6,7 @@ export type Item = {
group: Group
requestId: RequestID
href: string
props?: Partial<HTMLElement>
};
export type FontItem = {
@ -22,39 +23,39 @@ export default {
};
},
image(href: string): Item {
image(href: string, props?: Partial<HTMLElement>): Item {
return {
priority: 2,
group: 'images',
requestId: 'image',
href
href, props
};
},
css(href: string): Item {
css(href: string, props?: Partial<HTMLElement>): Item {
return {
priority: 3,
group: 'css',
requestId: 'css',
href
href, props
};
},
script(href: string): Item {
script(href: string, props?: Partial<HTMLElement>): Item {
return {
priority: 4,
group: 'scripts',
requestId: 'script',
href
href, props
};
},
json(href: string): Item {
json(href: string, props?: Partial<HTMLElement>): Item {
return {
priority: 5,
group: 'json',
requestId: 'json',
href
href, props
}
},

View file

@ -47,6 +47,7 @@ export default {
return fetch(href, fetchOptions())
.then((res) => res.text())
.then((text) => ({type: 'application/json', text}))
.then((props) => Object.assign(props, item.props || {}))
.then((props) => Object.assign(document.createElement('script'), props));
}
};