MCPcopy
hub / github.com/basecamp/trix / createElement

Method createElement

src/trix/views/piece_view.js:70–111  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

68 }
69
70 createElement() {
71 let element, key, value
72 const styles = {}
73
74 for (key in this.attributes) {
75 value = this.attributes[key]
76 const config = getTextConfig(key)
77 if (config) {
78 if (config.tagName) {
79 var innerElement
80 const pendingElement = makeElement(config.tagName)
81
82 if (innerElement) {
83 innerElement.appendChild(pendingElement)
84 innerElement = pendingElement
85 } else {
86 element = innerElement = pendingElement
87 }
88 }
89
90 if (config.styleProperty) {
91 styles[config.styleProperty] = value
92 }
93
94 if (config.style) {
95 for (key in config.style) {
96 value = config.style[key]
97 styles[key] = value
98 }
99 }
100 }
101 }
102
103 if (Object.keys(styles).length) {
104 if (!element) { element = makeElement("span") }
105 for (key in styles) {
106 value = styles[key]
107 element.style[key] = value
108 }
109 }
110 return element
111 }
112
113 createContainerElement() {
114 for (const key in this.attributes) {

Callers 13

createNodesMethod · 0.95
createLinkHTMLMethod · 0.45
makeElementFunction · 0.45
installFunction · 0.45
setFixtureHTMLFunction · 0.45
pressCommandBackspaceFunction · 0.45
pasting_test.jsFile · 0.45

Calls 2

getTextConfigFunction · 0.90
makeElementFunction · 0.90

Tested by

no test coverage detected