pull/4923/head
pushkine 5 years ago
parent 1157cee42a
commit 5a7d1c05c8

@ -152,16 +152,13 @@ export function children(element) {
} }
export function claim_element(nodes, name, attributes, svg) { export function claim_element(nodes, name, attributes, svg) {
for (let i = 0; i < nodes.length; i += 1) { for (let i = 0, j = 0, node, attr; i < nodes.length; i += 1) {
const node = nodes[i]; if ((node = nodes[i]).nodeName === name) {
if (node.nodeName === name) {
let j = 0;
while (j < node.attributes.length) { while (j < node.attributes.length) {
const attribute = node.attributes[j]; if (attributes[attr = node.attributes[j].name]) {
if (attributes[attribute.name]) {
j++; j++;
} else { } else {
node.removeAttribute(attribute.name); node.removeAttribute(attr);
} }
} }
return nodes.splice(i, 1)[0]; return nodes.splice(i, 1)[0];
@ -172,14 +169,12 @@ export function claim_element(nodes, name, attributes, svg) {
} }
export function claim_text(nodes, data) { export function claim_text(nodes, data) {
for (let i = 0; i < nodes.length; i += 1) { for (let i = 0, node; i < nodes.length; i += 1) {
const node = nodes[i]; if ((node = nodes[i]).nodeType === 3) {
if (node.nodeType === 3) {
node.data = '' + data; node.data = '' + data;
return nodes.splice(i, 1)[0]; return nodes.splice(i, 1)[0];
} }
} }
return text(data); return text(data);
} }
@ -209,10 +204,8 @@ export function set_style(node, key, value, important) {
} }
export function select_option(select, value) { export function select_option(select, value) {
for (let i = 0; i < select.options.length; i += 1) { for (let i = 0, option; i < select.options.length; i += 1) {
const option = select.options[i]; if ((option = select.options[i]).__value === value) {
if (option.__value === value) {
option.selected = true; option.selected = true;
return; return;
} }
@ -220,15 +213,13 @@ export function select_option(select, value) {
} }
export function select_options(select, value) { export function select_options(select, value) {
for (let i = 0; i < select.options.length; i += 1) { for (let i = 0, option; i < select.options.length; i += 1) {
const option = select.options[i]; (option = select.options[i]).selected = ~value.indexOf(option.__value);
option.selected = ~value.indexOf(option.__value);
} }
} }
export function select_value(select) { export function select_value(select) {
const selected_option = select.querySelector(':checked') || select.options[0]; return (select = select.querySelector(':checked') || select.options[0]) && select.__value;
return selected_option && selected_option.__value;
} }
export function select_multiple_value(select) { export function select_multiple_value(select) {

Loading…
Cancel
Save