MCPcopy
hub / github.com/tinymce/tinymce / attr

Method attr

modules/tinymce/src/core/main/ts/api/html/Node.ts:179–235  ·  view source on GitHub ↗
(name?: string | Record<string, string | null | undefined>, value?: string | null)

Source from the content-addressed store, hash-verified

177 public attr(name: Record<string, string | null | undefined> | undefined): AstNode | undefined;
178 public attr(name: string): string | undefined;
179 public attr(name?: string | Record<string, string | null | undefined>, value?: string | null): string | AstNode | undefined {
180 const self = this;
181
182 if (!Type.isString(name)) {
183 if (Type.isNonNullable(name)) {
184 Obj.each(name, (value, key) => {
185 self.attr(key, value);
186 });
187 }
188
189 return self;
190 }
191
192 const attrs = self.attributes;
193 if (attrs) {
194 if (value !== undefined) {
195 // Remove attribute
196 if (value === null) {
197 if (name in attrs.map) {
198 delete attrs.map[name];
199
200 let i = attrs.length;
201 while (i--) {
202 if (attrs[i].name === name) {
203 attrs.splice(i, 1);
204 return self;
205 }
206 }
207 }
208
209 return self;
210 }
211
212 // Set attribute
213 if (name in attrs.map) {
214 // Set attribute
215 let i = attrs.length;
216 while (i--) {
217 if (attrs[i].name === name) {
218 attrs[i].value = value;
219 break;
220 }
221 }
222 } else {
223 attrs.push({ name, value });
224 }
225
226 attrs.map[name] = value;
227
228 return self;
229 }
230
231 return attrs.map[name];
232 }
233
234 return undefined;
235 }
236

Callers 15

getFontTreeFunction · 0.95
createSafeEmbedFunction · 0.95
registerFunction · 0.95
paddEmptyNodeFunction · 0.95
transferChildrenFunction · 0.95
createMethod · 0.95
converterFunction · 0.95
converterFunction · 0.95
updateHtmlFunction · 0.95
createPlaceholderNodeFunction · 0.95
createPreviewNodeFunction · 0.95
padInputNodeFunction · 0.95

Calls 1

eachMethod · 0.80

Tested by

no test coverage detected