Skip to content

Commit

Permalink
✨ Improve
Browse files Browse the repository at this point in the history
  • Loading branch information
damianpumar committed Mar 6, 2024
1 parent 1e217a5 commit 6080776
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,16 @@ export default {
position.top + this.$refs.spanEntityRef.scrollTop
}px`;
},
getScrollParent(element) {
if (!element) {
return undefined;
}
if (!element) return;
let parent = element.parentElement;
while (parent) {
const { overflow } = window.getComputedStyle(parent);
if (overflow.split(" ").every((o) => o === "auto" || o === "scroll")) {
return parent;
}
parent = parent.parentElement;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ export class Highlighting {
}

mount(selections: Omit<Span, "text" | "node">[] = []) {
if (!CSS.highlights) {
throw new Error(
"The CSS Custom Highlight API is not supported in this browser!"
);
}

const node = document.getElementById(this.nodeId)!;

if (!node) throw new Error(`Node with id ${this.nodeId} not found`);
Expand All @@ -105,12 +111,6 @@ export class Highlighting {
}

private loadHighlights(selections: Omit<Span, "text" | "node">[] = []) {
if (!CSS.highlights) {
throw new Error(
"The CSS Custom Highlight API is not supported in this browser!"
);
}

if (!this.node) {
throw new Error(
"Node not attached, use `attachNode` method with HTMLElement that contains the text to select"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
@on-focus="onFocus"
@on-selected="onSelected"
/>
<div>
<p>Values</p>
{{ JSON.stringify(question.answer.valuesAnswered) }}
</div>
</div>
</template>

Expand Down

0 comments on commit 6080776

Please sign in to comment.