Skip to content

Commit d9c4fbb

Browse files
committed
fix: ui color input attributes
1 parent 75a989a commit d9c4fbb

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/UI/Components/Slider.js

+9-10
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,6 @@ export default def(class Slider extends Component {
7575
`;
7676

7777
create_template ({ template }) {
78-
const min = this.get('min');
79-
const max = this.get('max');
80-
const value = this.get('value') ?? min;
81-
const step = this.get('step') ?? 1;
8278
const label = this.get('label') ?? this.get('name');
8379

8480
$(template).html(/*html*/`
@@ -87,17 +83,20 @@ export default def(class Slider extends Component {
8783
<input class="slider-input" type="range">
8884
</div>
8985
`);
90-
91-
// Set attributes here to prevent XSS injection
92-
$(template).find('.slider-input').attr('min', min);
93-
$(template).find('.slider-input').attr('max', max);
94-
$(template).find('.slider-input').attr('value', value);
95-
$(template).find('.slider-input').attr('step', step);
9686
}
9787

9888
on_ready ({ listen }) {
9989
const input = this.dom_.querySelector('.slider-input');
10090

91+
// Set attributes here to prevent XSS injection
92+
{
93+
const min = this.get('min');
94+
input.setAttribute('min', min);
95+
input.setAttribute('max', this.get('max'));
96+
input.setAttribute('step', this.get('step') ?? 1);
97+
input.value = this.get('value') ?? min;
98+
}
99+
101100
input.addEventListener('input', e => {
102101
const on_change = this.get('on_change');
103102
if (on_change) {

0 commit comments

Comments
 (0)