mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Auto merge of #13028 - ofekd:implement-data-value-attr, r=KiChjang
Implement HTMLDataElement#value <!-- Please describe your changes on the following line: --> Implement HTMLDataElement#value --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #12966 <!-- Either: --> - [X] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13028) <!-- Reviewable:end -->
This commit is contained in:
commit
6beec195ed
6 changed files with 82 additions and 136 deletions
|
@ -0,0 +1,66 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>HTMLDataElement.value getting</title>
|
||||
<link rel="author" title="ofekd" href="mailto:ofek@outlook.com">
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/semantics.html#dom-data-value">
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<div id="container">
|
||||
<data value=""></data>
|
||||
<data value="40">Forty</data>
|
||||
</div>
|
||||
<script>
|
||||
var newData, datasArr, container;
|
||||
|
||||
container = document.getElementById('container')
|
||||
|
||||
newData = document.createElement('data');
|
||||
newData.textContent = 'Five';
|
||||
newData.setAttribute('value', '5');
|
||||
container.appendChild(newData);
|
||||
|
||||
datasArr = container.getElementsByTagName('data');
|
||||
|
||||
test(function () {
|
||||
test(function() {
|
||||
assert_equals(datasArr[0].value, '');
|
||||
}, 'data[value] #0 getter test');
|
||||
|
||||
test(function() {
|
||||
assert_equals(datasArr[1].value, '40');
|
||||
}, 'data[value] #1 getter test');
|
||||
|
||||
test(function() {
|
||||
assert_equals(datasArr[2].value, '5');
|
||||
}, 'data[value] #2 getter test');
|
||||
}, 'Getter tests');
|
||||
|
||||
test(function () {
|
||||
var i;
|
||||
|
||||
for (i = 0; i < datasArr.length; i++) {
|
||||
datasArr[i].textContent = 'Twenty';
|
||||
datasArr[i].value = 20;
|
||||
|
||||
test(function() {
|
||||
assert_equals(datasArr[i].getAttribute('value'), '20');
|
||||
}, 'data[value] #' + i + ' setter test');
|
||||
}
|
||||
|
||||
newData = document.createElement('data');
|
||||
newData.textContent = 'Twenty';
|
||||
newData.value = '20';
|
||||
container.appendChild(newData);
|
||||
|
||||
test(function() {
|
||||
assert_equals(datasArr[3].getAttribute('value'), '20');
|
||||
}, 'data[value] #3 setter test');
|
||||
|
||||
}, 'Setter tests');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue