Skip to content

Commit

Permalink
fix: Add crossorigin as valid img tag attribute (#918)
Browse files Browse the repository at this point in the history
* fix: add crossorigin as valid img tag attribute

* fix: add crossorigin to audio and video elements
  • Loading branch information
pmdartus authored Jan 8, 2019
1 parent a3d6af5 commit e861600
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<template>
<!-- Issue #917 -->
<img src="http://www.example.com/image.png" crossorigin="anonymous">
<video src="http://www.example.com/video.mp4" crossorigin="anonymous"></video>
<audio src="http://www.example.com/video.mp3" crossorigin="anonymous"></audio>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { registerTemplate } from "lwc";

function tmpl($api, $cmp, $slotset, $ctx) {
const { h: api_element } = $api;
return [
api_element(
"img",
{
attrs: {
src: "http://www.example.com/image.png",
crossorigin: "anonymous"
},
key: 2
},
[]
),
api_element(
"video",
{
attrs: {
src: "http://www.example.com/video.mp4",
crossorigin: "anonymous"
},
key: 3
},
[]
),
api_element(
"audio",
{
attrs: {
src: "http://www.example.com/video.mp3",
crossorigin: "anonymous"
},
key: 4
},
[]
)
];
}

export default registerTemplate(tmpl);
tmpl.stylesheets = [];
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"warnings": [],
"metadata": {
"definedSlots": [],
"templateUsedIds": [],
"templateDependencies": []
}
}
5 changes: 5 additions & 0 deletions packages/@lwc/template-compiler/src/parser/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,11 @@ export const HTML_ATTRIBUTES_REVERSE_LOOKUP: { [attr: string]: string[] } = {
'coords': [
'area',
],
'crossorigin': [
'img',
'audio',
'video'
],
'data': [
'object',
],
Expand Down

0 comments on commit e861600

Please sign in to comment.