How to use throwElementError method in root

Best JavaScript code snippet using root

speckle.js

Source:speckle.js Github

copy

Full Screen

...23 // augment the instance count on the class, not the instance.24 Speckle.instance++;25 // throw error if `element` is not a valid HTML element.26 if (! element || ! (element instanceof Element)) {27 this.throwElementError();28 }29 this.element = element;30 // Set the default options.31 this.defaultOptions = {32 quantity: 56, // quantity of speckles33 minSize: 4, // smallest speckle (1+, less than `maxSize`, px)34 maxSize: 56, // largest speckle (1+, greater than `minSize`, px)35 tbOffset: 8, // top/bottom offset (0+, %)36 lrOffset: 8, // left/right offset (0+, %)37 minOpacity: 12.5, // minimum opacity (1-100)38 maxOpacity: 87.5, // maximum opacity (1-100)39 isBokeh: false, // bokeh effect (blur as a factor of distance)40 color: '', // color (hex, rgb, hsl, keyword). If none, the colors will be randomized.41 zIndex: 0, // z-index (bokeh: the starting z-index)42 isCropped: false, // apply `overflow: hidden;` to the container43 tagName: 'I', // the Tag Name that the speckle should be rendered as44 attributes: null // attributes object as `key: value` pairs45 };46 // Parse and set options.47 this.options = this.parseOptions(options, this.defaultOptions);48 const { minSize, maxSize, tbOffset, lrOffset, minOpacity, maxOpacity } = this.options;49 // throw error if `minSize` is less than 1, or greater than `maxSize`.50 if ((minSize < 1) || (minSize > maxSize)) {51 this.throwOptionsError('minSize');52 }53 // throw error if `maxSize` is less than 1, or less than `minSize`.54 if ((maxSize < 1) || (maxSize < minSize)) {55 this.throwOptionsError('maxSize');56 }57 // throw error if `tbOffset` is less than 0.58 if (tbOffset < 0) {59 this.throwOptionsError('tbOffset');60 }61 // throw error if `lrOffset` is less than 0.62 if (lrOffset < 0) {63 this.throwOptionsError('lrOffset');64 }65 // throw error if `minOpacity` is less than 0 or greater than 100; or if is greater than `maxOpacity`.66 if ((minOpacity < 0) || (minOpacity > 100) || (minOpacity > maxOpacity)) {67 this.throwOptionsError('minOpacity');68 }69 // throw error if `maxOpacity` is less than 0 or greater than 100; or if is less than `minOpacity`.70 if ((maxOpacity < 0) || (maxOpacity > 100) || (maxOpacity < minOpacity)) {71 this.throwOptionsError('maxOpacity');72 }73 // Set the global styles.74 this.globalStyles = {75 borderRadius: '50%', 76 display: 'block', 77 pointerEvents: 'none', 78 position: 'absolute', 79 };80 // Set the upgraded class.81 this.upgradedClass = 'speckle--upgraded';82 // Render speckles.83 this.render();84 }85 /**86 * Parse the passed options against the defaults.87 * 88 * @param {obj} options The passed in user options object.89 * @param {obj} defaultOptions The default options object.90 * @return {obj} The parsed options object.91 */92 parseOptions(options, defaultOptions) {93 // if no options are passed, just return the default options.94 if (! options || typeof options !== 'object') {95 return defaultOptions;96 }97 // init empty `parsedOptions` object.98 var parsedOptions = {};99 // loop default option keys and parse. If the options 100 // object has this key, use it; else, use the default option.101 for (var key in defaultOptions) {102 const value = options[key];103 // If the value is a number, set it no matter what.104 // This prevents issues where passing `0` is read as 105 // no option passed, rendering the default instead.106 if (typeof value === 'number') {107 parsedOptions[key] = value;108 } else {109 parsedOptions[key] = value || defaultOptions[key];110 }111 }112 // return the parsed options.113 return parsedOptions;114 }115 /**116 * Throw an element error.117 * 118 * @since 0.0.1119 * @return {Error} The formatted element error.120 */121 throwElementError() {122 throw new Error(123 'Speckle.js\n' + 124 'A valid HTML Element must be passed to the constructor as the first argument.'125 );126 }127 /**128 * Throw an element error.129 * 130 * @since 0.0.1131 * @return {Error} The formatted element error.132 */133 throwOptionsError(key) {134 var message = '';135 if (key === 'minSize') {...

Full Screen

Full Screen

Navigate.ts

Source:Navigate.ts Github

copy

Full Screen

...33 control: keyof KeyboardMap.Controls34) => {35 const element = document.querySelector(`${controls.selector} .${C.FOCUSED_CLASS}`)36 if (!element || !element.parentElement) {37 return throwElementError(controls.selector)38 }39 switch (action) {40 case ":current": {41 return Events.click(element)42 }43 case ":prev": {44 return prevNext("previous", element, controls, map)45 }46 case ":next": {47 return prevNext("next", element, controls, map)48 }49 case ":prev:parent": {50 return prevNextParent("previous", element, controls, map)51 }52 case ":next:parent": {53 return prevNextParent("next", element, controls, map)54 }55 case ":complex": {56 return handleComplex(element, map, control)57 }58 default:59 throw new Error(`Unhandled Action ${action}`)60 }61}62const handleLinks = (controls: KeyboardMap.Controls, child: number) => {63 handleMaps(controls, child)64}65const handleMaps = (controls: KeyboardMap.Controls, child: number = 0) => {66 const element = document.querySelector(controls.selector)67 if (element) {68 const pos = Math.min(element.children.length - 1, child)69 Events.click(element.children[pos])70 } else {71 throwElementError(controls.selector)72 }73}74const handleComplex = (element: Element, map: KeyboardMap.MapKeys, control: keyof KeyboardMap.Controls) => {75 const index = _.childIndex(element)76 const complex = MapComplex[map][control][index] as KeyboardMap.Links77 const [m, child] = complex.split("@")78 return handleLinks(MapObject[m], parseInt(child, 10))79}80const prevNext = (dir: Direction, el: Element, controls: KeyboardMap.Controls, map: KeyboardMap.MapKeys) => {81 const sibling = el[`${dir}ElementSibling`]82 const control = dir === "next" ? "rightLast" : "leftFirst"83 const action = controls[control]84 if (sibling) {85 Events.click(sibling)...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var rootElement = require('../pages/rootElement.js');2var element = new rootElement();3var elementLocator = element.rootElementLocator;4var rootElement = require('../pages/rootElement.js');5var element = new rootElement();6var elementLocator = element.rootElementLocator;7var rootElementLocator = require('../pages/rootElementLocator.js');8var element = new rootElementLocator();9var elementLocator = element.rootElementLocator;10var rootElementLocator = require('../pages/rootElementLocator.js');11var element = new rootElementLocator();12var elementLocator = element.rootElementLocator;13var rootElementLocator = require('../pages/rootElementLocator.js');14var element = new rootElementLocator();15var elementLocator = element.rootElementLocator;16var rootElementLocator = require('../pages/rootElementLocator.js');17var element = new rootElementLocator();18var elementLocator = element.rootElementLocator;19var rootElementLocator = require('../pages/rootElementLocator.js');20var element = new rootElementLocator();21var elementLocator = element.rootElementLocator;22var rootElementLocator = require('../pages/rootElementLocator.js');23var element = new rootElementLocator();24var elementLocator = element.rootElementLocator;

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run root automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful