{"record":{"id":"60a0c5a445dba1dc","repo":"greensock/GSAP","slug":"element-not-found","errorCode":null,"errorMessage":"Element not found:","messagePattern":"Element not found:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/Flip.js","lineNumber":25,"sourceCode":" * @author: Jack Doyle, jack@greensock.com\n*/\n/* eslint-disable */\n\nimport { getGlobalMatrix, _getDocScrollTop, _getDocScrollLeft, Matrix2D, _setDoc, _getCTM } from \"./utils/matrix.js\";\n\nlet _id = 1,\n\t_toArray, gsap, _batch, _batchAction, _body, _closestTenth, _getStyleSaver,\n\t_forEachBatch = (batch, name) => batch.actions.forEach(a => a.vars[name] && a.vars[name](a)),\n\t_batchLookup = {},\n\t_RAD2DEG = 180 / Math.PI,\n\t_DEG2RAD = Math.PI / 180,\n\t_emptyObj = {},\n\t_dashedNameLookup = {},\n\t_memoizedRemoveProps = {},\n\t_listToArray = list => typeof(list) === \"string\" ? list.split(\" \").join(\"\").split(\",\") : list, // removes extra spaces contaminating the names, returns an Array.\n\t_callbacks = _listToArray(\"onStart,onUpdate,onComplete,onReverseComplete,onInterrupt\"),\n\t_removeProps = _listToArray(\"transform,transformOrigin,width,height,position,top,left,opacity,zIndex,maxWidth,maxHeight,minWidth,minHeight\"),\n\t_getEl = target => _toArray(target)[0] || console.warn(\"Element not found:\", target),\n\t_round = value => Math.round(value * 10000) / 10000 || 0,\n\t_toggleClass = (targets, className, action) => targets.forEach(el => el.classList[action](className)),\n\t_reserved = {zIndex:1, kill:1, simple:1, spin:1, clearProps:1, targets:1, toggleClass:1, onComplete:1, onUpdate:1, onInterrupt:1, onStart:1, delay:1, repeat:1, repeatDelay:1, yoyo:1, scale:1, fade:1, absolute:1, props:1, onEnter:1, onLeave:1, custom:1, paused:1, nested:1, prune:1, absoluteOnLeave: 1},\n\t_fitReserved = {zIndex:1, simple:1, clearProps:1, scale:1, absolute:1, fitChild:1, getVars:1, props:1},\n\t_camelToDashed = p => p.replace(/([A-Z])/g, \"-$1\").toLowerCase(),\n\t_copy = (obj, exclude) => {\n\t\tlet result = {}, p;\n\t\tfor (p in obj) {\n\t\t\texclude[p] || (result[p] = obj[p]);\n\t\t}\n\t\treturn result;\n\t},\n\t_memoizedProps = {},\n\t_memoizeProps = props => {\n\t\tlet p = _memoizedProps[props] = _listToArray(props);\n\t\t_memoizedRemoveProps[props] = p.concat(_removeProps);\n\t\treturn p;\n\t},","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/greensock/GSAP/blob/13e2b790546426a1a2e0e9b409f3f8dc6d6611f2/src/Flip.js#L7-L43","documentation":"Flip's _getEl helper resolves a target selector/element to the first match via gsap.utils.toArray. If nothing matches (empty array) it warns \"Element not found:\" with the target and returns undefined (the console.warn return value). Callers like _parseElementState then build an ElementState with a null element.","triggerScenarios":"Passing Flip.getState() / Flip.from() / Flip.to() a selector that matches no DOM element, e.g. class typo, element not yet mounted, or target removed before the call.","commonSituations":"Calling Flip before React/Vue renders the elements; wrong selector string; running before document ready; conditional rendering removed the element.","solutions":["Verify document.querySelector(selector) returns the element before calling Flip APIs","Run Flip calls after mount/render (e.g. useEffect, mounted hook)","Fix selector typos and ensure only one matching element is intended","Pass an actual element reference instead of a selector string"],"exampleFix":"// before\nconst state = Flip.getState('.boxx'); // typo, no match\n// after\nconst el = document.querySelector('.box');\nif (el) {\n  const state = Flip.getState(el);\n}","handlingStrategy":"validation","validationCode":"const el = document.querySelector(selector);\nif (!el) throw new Error(`Flip target not found: ${selector}`);\nconst state = Flip.getState(el);","typeGuard":"function elementExists(target) {\n  const el = typeof target === 'string' ? document.querySelector(target) : target;\n  return el instanceof Element;\n}","tryCatchPattern":null,"preventionTips":["Run Flip calls after DOM mount/render","Test selectors in the console before use","Re-query elements after conditional renders","Prefer element references over string selectors in framework code"],"tags":["flip","dom","selector","element-not-found"],"backgroundTag":"element-not-found","analyzedSha":"13e2b790546426a1a2e0e9b409f3f8dc6d6611f2","analyzedAt":"2026-08-29T08:34:05.027Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}