Skip to content

Commit

Permalink
Fix any outstanding type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpap committed Feb 29, 2024
1 parent 09ced81 commit 01ebaf0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
4 changes: 3 additions & 1 deletion panel/models/customselect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ export class CustomSelectView extends SelectView {

protected override options_el(): HTMLOptionElement[] | HTMLOptGroupElement[] {
const opts = super.options_el()
const {disabled_options} = this.model
opts.forEach((element) => {
if (this.model.disabled_options.includes(element.value)) {
// XXX: what about HTMLOptGroupElement?
if (element instanceof HTMLOptionElement && disabled_options.includes(element.value)) {
element.setAttribute("disabled", "true")
}
})
Expand Down
4 changes: 2 additions & 2 deletions panel/models/event-to-object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ const elementTransformCategories: any = {
hasCurrentTime: (element: any) => ({
currentTime: element.currentTime,
}),
hasFiles: (element: any) => {
hasFiles: (element: HTMLInputElement) => {
if (element?.type === "file") {
return {
files: Array.from(element.files).map((file: File) => ({
files: [...element.files ?? []].map((file) => ({
lastModified: file.lastModified,
name: file.name,
size: file.size,
Expand Down
4 changes: 2 additions & 2 deletions panel/models/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export class JSONView extends PanelMarkupView {
let json
try {
json = window.JSON.parse(text)
} catch (err) {
this.container.innerHTML = `<b>Invalid JSON:</b> ${err.toString()}`
} catch (err: unknown) {
this.container.innerHTML = `<b>Invalid JSON:</b> ${err}`
return
}
const config = {hoverPreviewEnabled: this.model.hover_preview, theme: this.model.theme}
Expand Down
8 changes: 4 additions & 4 deletions panel/models/quill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class QuillInputView extends HTMLBoxView {
* Original implementation relies on Selection.addRange to programmatically set the range, which does not work
* in Webkit with Native Shadow. Selection.addRange works fine in Chromium and Gecko.
**/
this.quill.selection.setNativeRange = (startNode: any, startOffset: any) => {
this.quill.selection.setNativeRange = (startNode: Element, startOffset: number) => {
let endNode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : startNode
let endOffset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : startOffset
const force = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false
Expand All @@ -133,11 +133,11 @@ export class QuillInputView extends HTMLBoxView {
const native = (this.quill.selection.getNativeRange() || {}).native
if (native == null || force || startNode !== native.startContainer || startOffset !== native.startOffset || endNode !== native.endContainer || endOffset !== native.endOffset) {
if (startNode.tagName == "BR") {
startOffset = [].indexOf.call(startNode.parentNode.childNodes, startNode)
startNode = startNode.parentNode
startOffset = Array.prototype.indexOf.call(startNode.parentNode?.childNodes ?? [], startNode)
startNode = startNode.parentNode as any
}
if (endNode.tagName == "BR") {
endOffset = [].indexOf.call(endNode.parentNode.childNodes, endNode)
endOffset = Array.prototype.indexOf(endNode.parentNode?.childNodes ?? [], endNode)
endNode = endNode.parentNode
}
selection.setBaseAndExtent(startNode, startOffset, endNode, endOffset)
Expand Down

0 comments on commit 01ebaf0

Please sign in to comment.