File tree Expand file tree Collapse file tree 3 files changed +13
-9
lines changed Expand file tree Collapse file tree 3 files changed +13
-9
lines changed Original file line number Diff line number Diff line change 11import { Attribute } from "./attribute.js" ;
2- import { isEmpty } from "./utils.js" ;
2+ import { isEmpty , hasValue } from "./utils.js" ;
33
44/**
55 * Encapsulate DOM element for Unicorn-related information.
@@ -166,11 +166,7 @@ export class Element {
166166 * A key that takes into consideration the db name and pk.
167167 */
168168 dbKey ( ) {
169- if (
170- ! isEmpty ( this . db ) &&
171- typeof this . db . pk !== "undefined" &&
172- typeof this . db . name !== "undefined"
173- ) {
169+ if ( hasValue ( this . db ) && hasValue ( this . db . pk ) && hasValue ( this . db . name ) ) {
174170 return `${ this . db . name } :${ this . db . pk } ` ;
175171 }
176172
@@ -203,7 +199,7 @@ export class Element {
203199 * Sets the value of an element. Tries to deal with HTML weirdnesses.
204200 */
205201 setValue ( val ) {
206- if ( typeof this . el . type === "undefined" ) {
202+ if ( isEmpty ( this . el . type ) ) {
207203 return ;
208204 }
209205
Original file line number Diff line number Diff line change 11import { Component } from "./component.js" ;
2+ import { hasValue } from "./utils.js" ;
23
34let messageUrl = "" ;
45const csrfTokenHeaderName = "X-CSRFToken" ;
@@ -33,7 +34,7 @@ export function call(componentName, methodName) {
3334 let component ;
3435
3536 Object . keys ( components ) . forEach ( ( id ) => {
36- if ( typeof component === "undefined" ) {
37+ if ( hasValue ( component ) ) {
3738 const _component = components [ id ] ;
3839
3940 if ( _component . name === componentName ) {
Original file line number Diff line number Diff line change 11/**
2- * Checks if an object is empty. Useful for check if a dictionary has any values .
2+ * Checks if an object is empty. Useful to check if a dictionary has a value .
33 */
44export function isEmpty ( obj ) {
55 return (
@@ -9,6 +9,13 @@ export function isEmpty(obj) {
99 ) ;
1010}
1111
12+ /**
13+ * Checks if an object has a value.
14+ */
15+ export function hasValue ( obj ) {
16+ return ! isEmpty ( obj ) ;
17+ }
18+
1219/**
1320 * Checks if a string has the search text.
1421 */
You can’t perform that action at this time.
0 commit comments