@progress/kendo-angular-common
Version:
Kendo UI for Angular - Utility Package
50 lines (49 loc) • 1.49 kB
JavaScript
/**-----------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the project root for more information
*-------------------------------------------------------------------------------------------*/
import { isPresent } from "./ng-class-parser";
import { take } from "rxjs/operators";
/**
* @hidden
*/
export const setHTMLAttributes = (attributes, renderer, element, zone) => {
if (zone) {
zone.onStable.pipe(take(1)).subscribe(() => {
applyAttributes(attributes, renderer, element);
});
}
else {
applyAttributes(attributes, renderer, element);
}
};
/**
* @hidden
*/
export const removeHTMLAttributes = (attributes, renderer, element) => {
for (const attribute in attributes) {
if (attribute) {
renderer.removeAttribute(element, attribute);
}
}
};
/**
* @hidden
*/
export const parseAttributes = (target, source) => {
const targetObj = target;
Object.keys(source).forEach(key => {
delete targetObj[key];
});
return targetObj;
};
/**
* @hidden
*/
export const applyAttributes = (attributes, renderer, element) => {
for (const attribute in attributes) {
if (attribute && isPresent(attributes[attribute])) {
renderer.setAttribute(element, attribute, attributes[attribute]);
}
}
};