MCPcopy Index your code
hub / github.com/gridstack/gridstack.js / _writeAttr

Method _writeAttr

src/gridstack.ts:1940–1960  ·  view source on GitHub ↗

@internal call to write any default attributes back to element

(el: HTMLElement, node: GridStackNode)

Source from the content-addressed store, hash-verified

1938
1939 /** @internal call to write any default attributes back to element */
1940 protected _writeAttr(el: HTMLElement, node: GridStackNode): GridStack {
1941 if (!node) return this;
1942 this._writePosAttr(el, node);
1943
1944 const attrs /*: GridStackWidget but strings */ = { // remaining attributes
1945 // autoPosition: 'gs-auto-position', // no need to write out as already in node and doesn't affect CSS
1946 noResize: 'gs-no-resize',
1947 noMove: 'gs-no-move',
1948 locked: 'gs-locked',
1949 id: 'gs-id',
1950 sizeToContent: 'gs-size-to-content',
1951 };
1952 for (const key in attrs) {
1953 if (node[key]) { // 0 is valid for x,y only but done above already and not in list anyway
1954 el.setAttribute(attrs[key], String(node[key]));
1955 } else {
1956 el.removeAttribute(attrs[key]);
1957 }
1958 }
1959 return this;
1960 }
1961
1962 /** @internal call to read any default attributes from element */
1963 protected _readAttr(el: HTMLElement, clearDefaultAttr = true): GridStackWidget {

Callers 2

updateMethod · 0.95
_prepareElementMethod · 0.95

Calls 1

_writePosAttrMethod · 0.95

Tested by

no test coverage detected