MCPcopy
hub / github.com/GrapesJS/grapesjs / getData

Function getData

packages/core/src/utils/cash-dom.ts:482–502  ·  view source on GitHub ↗
(ele, key)

Source from the content-addressed store, hash-verified

480// @require ./get_data_cache.js
481
482function getData(ele, key) {
483 var cache = getDataCache(ele);
484
485 if (key) {
486 if (!(key in cache)) {
487 var value = ele.dataset ? ele.dataset[key] || ele.dataset[camelCase(key)] : cash(ele).attr('data-' + key);
488
489 if (value !== undefined) {
490 try {
491 value = JSON.parse(value);
492 } catch (e) {}
493
494 cache[key] = value;
495 }
496 }
497
498 return cache[key];
499 }
500
501 return cache;
502} // @require ./variables.js
503// @require ./get_data_cache.js
504
505function removeData(ele, key) {

Callers 1

cash-dom.tsFile · 0.85

Calls 4

getDataCacheFunction · 0.85
cashFunction · 0.85
camelCaseFunction · 0.70
parseMethod · 0.45

Tested by

no test coverage detected