2023-09-19 12:34:42 +02:00
|
|
|
export const prop_process= { setDeleteAttr };
|
2023-09-13 13:02:17 +02:00
|
|
|
import { isUndef } from './helpers.js';
|
2023-09-19 12:34:42 +02:00
|
|
|
function setDeleteAttr(obj, prop, val){
|
2023-09-13 13:02:17 +02:00
|
|
|
/* Issue
|
|
|
|
For some native attrs you can unset only to set empty string.
|
|
|
|
This can be confusing as it is seen in inspector `<… id=""`.
|
|
|
|
Options:
|
|
|
|
1. Leave it, as it is native behaviour
|
|
|
|
2. Sets as empty string and removes the corresponding attribute when also has empty string
|
|
|
|
*3. Sets as undefined and removes the corresponding attribute when "undefined" string discovered
|
|
|
|
4. Point 2. with checks for coincidence (e.g. use special string)
|
|
|
|
*/
|
|
|
|
Reflect.set(obj, prop, val);
|
2023-09-21 12:35:27 +02:00
|
|
|
if(!isUndef(val)) return;
|
|
|
|
if(obj instanceof HTMLElement && obj.getAttribute(prop)==="undefined")
|
|
|
|
return obj.removeAttribute(prop);
|
|
|
|
if(Reflect.get(obj, prop)==="undefined")
|
|
|
|
return Reflect.set(obj, prop, "");
|
2023-09-13 13:02:17 +02:00
|
|
|
}
|