Skip to content

Commit 02ddf04

Browse files
author
Shane Osbourne
committed
add helper fn for known strings
1 parent fb1d097 commit 02ddf04

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/dom-utils.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,11 @@ class Template {
5858
export function html (strings, ...values) {
5959
return new Template(strings, values)
6060
}
61+
62+
/**
63+
* @param {string} string
64+
* @return {Template}
65+
*/
66+
export function trustedUnsafe (string) {
67+
return html([string])
68+
}

src/features/duckplayer/components/ddg-video-overlay.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import dax from '../assets/dax.svg'
33
import { i18n } from '../text.js'
44
import { appendImageAsBackground } from '../util.js'
55
import { VideoOverlayManager } from '../video-overlay-manager.js'
6-
import { html } from '../../../dom-utils.js'
6+
import { html, trustedUnsafe } from '../../../dom-utils.js'
77

88
/**
99
* The custom element that we use to present our UI elements
@@ -55,7 +55,7 @@ export class DDGVideoOverlay extends HTMLElement {
5555
createOverlay () {
5656
const overlayElement = document.createElement('div')
5757
overlayElement.classList.add('ddg-video-player-overlay')
58-
const svgIcon = html([dax], [])
58+
const svgIcon = trustedUnsafe(dax)
5959
overlayElement.innerHTML = html`
6060
<div class="ddg-vpo-bg"></div>
6161
<div class="ddg-vpo-content">

src/features/duckplayer/icon-overlay.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { addTrustedEventListener, appendElement, VideoParams } from './util'
22
import dax from './assets/dax.svg'
33
import { i18n } from './text.js'
44
import { OpenInDuckPlayerMsg } from './overlay-messages.js'
5-
import { html } from '../../dom-utils.js'
5+
import { html, trustedUnsafe } from '../../dom-utils.js'
66

77
export const IconOverlay = {
88
/**
@@ -42,7 +42,7 @@ export const IconOverlay = {
4242

4343
overlayElement.setAttribute('class', 'ddg-overlay' + (extraClass ? ' ' + extraClass : ''))
4444
overlayElement.setAttribute('data-size', size)
45-
const svgIcon = html([dax], [])
45+
const svgIcon = trustedUnsafe(dax)
4646
overlayElement.innerHTML = html`
4747
<a class="ddg-play-privately" href="#">
4848
<div class="ddg-dax">

0 commit comments

Comments
 (0)