Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use isElement fot svg scrollIntoView support #1039

Merged
merged 1 commit into from
Jul 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/js/components/shepherd-text.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script>
import { afterUpdate } from 'svelte';
import { isElement, isFunction } from '../utils/type-check';
import { isHTMLElement, isFunction } from '../utils/type-check';

export let descriptionId, element, step;

Expand All @@ -11,7 +11,7 @@
text = text.call(step);
}

if (isElement(text)) {
if (isHTMLElement(text)) {
element.appendChild(text);
} else {
element.innerHTML = text;
Expand Down
4 changes: 2 additions & 2 deletions src/js/step.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import merge from 'deepmerge';
import { Evented } from './evented.js';
import autoBind from './utils/auto-bind.js';
import { isElement, isFunction, isUndefined } from './utils/type-check.js';
import { isElement, isHTMLElement, isFunction, isUndefined } from './utils/type-check.js';
import { bindAdvance } from './utils/bind.js';
import {
setupTooltip,
Expand Down Expand Up @@ -150,7 +150,7 @@ export class Step extends Evented {
this.tooltip = null;
}

if (isElement(this.el) && this.el.parentNode) {
if (isHTMLElement(this.el) && this.el.parentNode) {
this.el.parentNode.removeChild(this.el);
this.el = null;
}
Expand Down
4 changes: 2 additions & 2 deletions src/js/tour.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Evented } from './evented.js';
import { Step } from './step.js';
import autoBind from './utils/auto-bind.js';
import { isElement, isFunction, isString, isUndefined } from './utils/type-check.js';
import { isHTMLElement, isFunction, isString, isUndefined } from './utils/type-check.js';
import { cleanupSteps } from './utils/cleanup.js';
import { normalizePrefix, uuid } from './utils/general.js';
import ShepherdModal from './components/shepherd-modal.svelte';
Expand Down Expand Up @@ -295,7 +295,7 @@ export class Tour extends Evented {
}

// Focus the element that was focused before the tour started
if (isElement(this.focusedElBeforeOpen)) {
if (isHTMLElement(this.focusedElBeforeOpen)) {
this.focusedElBeforeOpen.focus();
}
}
Expand Down
10 changes: 9 additions & 1 deletion src/js/utils/type-check.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
/**
* Checks if `value` is classified as an `Element`.
* @param {*} value The param to check if it is an Element
*/
export function isElement(value) {
return value instanceof Element;
}

/**
* Checks if `value` is classified as an `HTMLElement`.
* @param {*} value The param to check if it is an HTMLElement
*/
export function isElement(value) {
export function isHTMLElement(value) {
return value instanceof HTMLElement;
}

Expand Down