ramka5.classList.remove('activeramk2');
ramka5.classList.remove('activeramk3');
ramka5.classList.add('activeramk4');
ramka5.classList.remove('activeramk5');
ramka5.classList.remove('activeramk6');
ramka5.classList.remove('activeramk7');
ramka5.classList.remove('activeramk8');
ramka5.classList.remove('activeramk9');
переделывается заменой класса на значение атрибута.ramka5.dataset.activeBorder = '4';
и изменением в css селектора .activeramk4
на [data-active-border="4"]
previousSibling, nextSibling возвращают какой-то #text
<!DOCTYPE html>
<html>
<head>
<title>My Page</title>
</head>
<body>
<!-- Page Body -->
<h2><font color="#3AC1EF">My Page</font></h2>
<p id="content">Thank you for visiting my web page!</p>
</body>
</html>
HTML
HEAD
#text "\n "
TITLE
#text "My Page"
#text "\n "
#text "\n "
BODY
#text "\n "
#comment " Page Body "
#text "\n "
H2
FONT
#text "My Page"
#text "\n n"
P
#text "Thank you for visiting my web page!"
#text "\n \n\n\n"
const has = (object, key) => (key in object);
const gendiff = (file1, file2) => {
const mergeFiles = { ...file1, ...file2 };
const uniqueKeys = Object.keys(mergeFiles);
const diff = uniqueKeys.map(key => {
if (has(file1, key) && has(file2, key) && typeof file1[key] === 'object' && typeof file2[key] === 'object') {
return { key, value: gendiff(file1[key], file2[key]), status: 'have a child' };
} else if (has(file1, key) && has(file2, key) && file1[key] !== file2[key]) {
return { key, value: { oldValue: file1[key], newValue: file2[key] }, status: 'changed' };
} else if (has(file1, key) && !has(file2, key)) {
return { key, value: file1[key], status: 'removed' };
} else if (!has(file1, key) && has(file2, key)) {
return { key, value: file2[key], status: 'new' };
} else if (has(file1, key) && has(file2, key) && file1[key] === file2[key]) {
return { key, value: file1[key], status: 'same' };
}
});
return diff;
};
console.log(gendiff(
{ workshop: { data: '2.0000000', locales: 'zh-CN.pak' } },
{ workshop: { config: 'd7', locales: 'am.pak' } }
));
/*
[
{
key: "workshop",
status: "have a child",
value: [
{ key: "data", value: "2.0000000", status: "removed" },
{
key: "locales",
status: "changed",
value: { oldValue: "zh-CN.pak", newValue: "am.pak" },
},
{ key: "config", value: "d7", status: "new" },
],
},
]
*/