MCPcopy Index your code
hub / github.com/OneNoteDev/WebClipper / dom

Function dom

src/scripts/highlighting/textHighlighter.js:189–414  ·  view source on GitHub ↗
(el)

Source from the content-addressed store, hash-verified

187 * @returns {object}
188 */
189 var dom = function (el) {
190
191 return /** @lends dom **/ {
192
193 /**
194 * Adds class to element.
195 * @param {string} className
196 */
197 addClass: function (className) {
198 if (el.classList) {
199 el.classList.add(className);
200 } else {
201 el.className += ' ' + className;
202 }
203 },
204
205 /**
206 * Removes class from element.
207 * @param {string} className
208 */
209 removeClass: function (className) {
210 if (el.classList) {
211 el.classList.remove(className);
212 } else {
213 el.className = el.className.replace(
214 new RegExp('(^|\\b)' + className + '(\\b|$)', 'gi'), ' '
215 );
216 }
217 },
218
219 /**
220 * Prepends child nodes to base element.
221 * @param {Node[]} nodesToPrepend
222 */
223 prepend: function (nodesToPrepend) {
224 var nodes = Array.prototype.slice.call(nodesToPrepend),
225 i = nodes.length;
226
227 while (i--) {
228 el.insertBefore(nodes[i], el.firstChild);
229 }
230 },
231
232 /**
233 * Appends child nodes to base element.
234 * @param {Node[]} nodesToAppend
235 */
236 append: function (nodesToAppend) {
237 var nodes = Array.prototype.slice.call(nodesToAppend);
238
239 for (var i = 0, len = nodes.length; i < len; ++i) {
240 el.appendChild(nodes[i]);
241 }
242 },
243
244 /**
245 * Inserts base element after refEl.
246 * @param {Node} refEl - node after which base element will be inserted

Callers 7

haveSameColorFunction · 0.85
sortByDepthFunction · 0.85
textHighlighter.jsFile · 0.85
flattenOnceFunction · 0.85
mergeSiblingTextNodesFunction · 0.85
removeHighlightFunction · 0.85
deserializationFnFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected