@sankhyalabs/core
Advanced tools
Comparing version 1.0.21 to 1.0.22
class FloatingEntry { | ||
constructor(parent, content, opts) { | ||
this.parent = WeakRef === undefined ? parent : new WeakRef(parent); | ||
this.content = WeakRef === undefined ? content : new WeakRef(content); | ||
try { | ||
this.weakRefParent = new WeakRef(parent); | ||
this.weakRefContent = new WeakRef(content); | ||
} | ||
catch (error) { | ||
this.strongRefParent = parent; | ||
this.strongRefContent = content; | ||
} | ||
this.options = opts; | ||
} | ||
get parent() { | ||
if (this.weakRefParent) { | ||
return this.weakRefParent.deref(); | ||
} | ||
return this.strongRefParent; | ||
} | ||
get content() { | ||
if (this.weakRefContent) { | ||
return this.weakRefContent.deref(); | ||
} | ||
return this.strongRefContent; | ||
} | ||
} | ||
@@ -26,4 +44,4 @@ export default class FloatingManager { | ||
if (!target || entry.options.autoClose) { | ||
const parent = (WeakRef === undefined ? entry.parent : entry.parent.deref()); | ||
const content = (WeakRef === undefined ? entry.content : entry.content.deref()); | ||
const parent = entry.parent; | ||
const content = entry.content; | ||
if (parent && content) { | ||
@@ -65,5 +83,3 @@ const innerClickFunction = entry.options.innerClickTest ? entry.options.innerClickTest : FloatingManager.innerClick; | ||
const entry = FloatingManager.entries[index]; | ||
const entryParent = (WeakRef === undefined ? entry.parent : entry.parent.deref()); | ||
const entryContent = (WeakRef === undefined ? entry.content : entry.content.deref()); | ||
if (entry && content === entryContent && parent === entryParent) { | ||
if (entry && content === entry.content && parent === entry.parent) { | ||
return index; | ||
@@ -70,0 +86,0 @@ } |
{ | ||
"name": "@sankhyalabs/core", | ||
"version": "1.0.21", | ||
"version": "1.0.22", | ||
"description": "Modulo core JavaScript da Sankhya.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -12,11 +12,32 @@ interface FloatingOptions { | ||
public parent: WeakRef<HTMLElement>|HTMLElement; | ||
public content: WeakRef<HTMLElement>|HTMLElement; | ||
private weakRefParent?: WeakRef<HTMLElement>; | ||
private weakRefContent?: WeakRef<HTMLElement>; | ||
private strongRefParent?: HTMLElement; | ||
private strongRefContent?: HTMLElement; | ||
public options: FloatingOptions; | ||
constructor(parent: HTMLElement, content: HTMLElement, opts: FloatingOptions) { | ||
this.parent = WeakRef === undefined ? parent : new WeakRef(parent); | ||
this.content = WeakRef === undefined ? content : new WeakRef(content); | ||
try{ | ||
this.weakRefParent = new WeakRef(parent); | ||
this.weakRefContent = new WeakRef(content); | ||
} catch(error){ | ||
this.strongRefParent = parent; | ||
this.strongRefContent = content; | ||
} | ||
this.options = opts; | ||
} | ||
public get parent():HTMLElement|undefined{ | ||
if(this.weakRefParent){ | ||
return this.weakRefParent.deref(); | ||
} | ||
return this.strongRefParent | ||
} | ||
public get content():HTMLElement|undefined{ | ||
if(this.weakRefContent){ | ||
return this.weakRefContent.deref(); | ||
} | ||
return this.strongRefContent; | ||
} | ||
} | ||
@@ -50,4 +71,4 @@ | ||
if (!target || entry.options.autoClose) { | ||
const parent: HTMLElement | undefined = (WeakRef === undefined ? entry.parent as HTMLElement : (entry.parent as WeakRef<HTMLElement>).deref()); | ||
const content: HTMLElement | undefined = (WeakRef === undefined ? entry.content as HTMLElement : (entry.content as WeakRef<HTMLElement>).deref()); | ||
const parent: HTMLElement | undefined = entry.parent; | ||
const content: HTMLElement | undefined = entry.content; | ||
@@ -96,5 +117,3 @@ if (parent && content) { | ||
const entry: FloatingEntry = FloatingManager.entries[index]; | ||
const entryParent: HTMLElement | undefined = (WeakRef === undefined ? entry.parent as HTMLElement : (entry.parent as WeakRef<HTMLElement>).deref()); | ||
const entryContent: HTMLElement | undefined = (WeakRef === undefined ? entry.content as HTMLElement : (entry.content as WeakRef<HTMLElement>).deref()); | ||
if (entry && content === entryContent && parent === entryParent) { | ||
if (entry && content === entry.content && parent === entry.parent) { | ||
return index; | ||
@@ -101,0 +120,0 @@ } |
Sorry, the diff of this file is not supported yet
176211
3444