MCPcopy
hub / github.com/shipshapecode/shepherd / parseAttachTo

Function parseAttachTo

shepherd.js/src/utils/general.ts:37–64  ·  view source on GitHub ↗
(step: Step)

Source from the content-addressed store, hash-verified

35 * `on` is a string position value
36 */
37export function parseAttachTo(step: Step) {
38 const options = step.options.attachTo || {};
39 const returnOpts = Object.assign({}, options);
40
41 if (isFunction(returnOpts.element)) {
42 // Bind the callback to step so that it has access to the object, to enable running additional logic
43 returnOpts.element = returnOpts.element.call(step);
44 }
45
46 if (isString(returnOpts.element)) {
47 // Can't override the element in user opts reference because we can't
48 // guarantee that the element will exist in the future.
49 try {
50 returnOpts.element = document.querySelector(
51 returnOpts.element
52 ) as HTMLElement;
53 } catch (_e) {
54 // TODO
55 }
56 if (!returnOpts.element) {
57 console.error(
58 `The element for this Shepherd step was not found ${options.element}`
59 );
60 }
61 }
62
63 return returnOpts;
64}
65
66/*
67 * Resolves the step's `extraHighlights` option, converting any locator values to HTMLElements.

Callers 2

general.spec.jsFile · 0.90

Calls 2

isFunctionFunction · 0.90
isStringFunction · 0.90

Tested by

no test coverage detected