@leafer/decorator 1.9.3 → 1.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer/decorator",
3
- "version": "1.9.3",
3
+ "version": "1.9.4",
4
4
  "description": "@leafer/decorator",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,11 +22,11 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/platform": "1.9.3",
26
- "@leafer/data": "1.9.3",
27
- "@leafer/debug": "1.9.3"
25
+ "@leafer/platform": "1.9.4",
26
+ "@leafer/data": "1.9.4",
27
+ "@leafer/debug": "1.9.4"
28
28
  },
29
29
  "devDependencies": {
30
- "@leafer/interface": "1.9.3"
30
+ "@leafer/interface": "1.9.4"
31
31
  }
32
32
  }
package/src/data.ts CHANGED
@@ -281,14 +281,14 @@ export function defineDataProcessor(target: ILeaf, key: string, defaultValue?: I
281
281
  property.get = function () { return this[computedKey] }
282
282
  } else if (typeof defaultValue === 'function') {
283
283
  property.get = function () {
284
- let v = this[computedKey]
285
- return v === undefined ? defaultValue((this as ILeafData).__leaf) : v
284
+ const v = this[computedKey]
285
+ return v == null ? defaultValue((this as ILeafData).__leaf) : v
286
286
  }
287
287
  } else if (isObject(defaultValue)) {
288
288
  const isEmpty = isEmptyData(defaultValue)
289
289
  property.get = function () {
290
- let v = this[computedKey]
291
- return v === undefined ? this[computedKey] = isEmpty ? {} : DataHelper.clone(defaultValue) : v
290
+ const v = this[computedKey]
291
+ return v == null ? this[computedKey] = isEmpty ? {} : DataHelper.clone(defaultValue) : v
292
292
  }
293
293
  }
294
294
 
@@ -296,7 +296,7 @@ export function defineDataProcessor(target: ILeaf, key: string, defaultValue?: I
296
296
  if (key === 'width') {
297
297
  property.get = function () {
298
298
  const v = this[computedKey]
299
- if (v === undefined) {
299
+ if (v == null) {
300
300
  const t = this as ILeafData, naturalWidth = t.__naturalWidth, leaf = t.__leaf
301
301
  if (!defaultValue || leaf.pathInputed) return leaf.boxBounds.width
302
302
  if (naturalWidth) return (t as IObject)._height && t.__useNaturalRatio ? (t as IObject)._height * naturalWidth / t.__naturalHeight : naturalWidth
@@ -306,7 +306,7 @@ export function defineDataProcessor(target: ILeaf, key: string, defaultValue?: I
306
306
  } else if (key === 'height') {
307
307
  property.get = function () {
308
308
  const v = this[computedKey]
309
- if (v === undefined) {
309
+ if (v == null) {
310
310
  const t = this as ILeafData, naturalHeight = t.__naturalHeight, leaf = t.__leaf
311
311
  if (!defaultValue || leaf.pathInputed) return leaf.boxBounds.height
312
312
  if (naturalHeight) return (t as IObject)._width && t.__useNaturalRatio ? (t as IObject)._width * naturalHeight / t.__naturalWidth : naturalHeight
package/src/object.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { IObject, IValue } from '@leafer/interface'
2
- import { isUndefined } from '@leafer/data'
3
2
 
4
3
  export function defineKey<T>(target: T, key: string, descriptor: IObject & ThisType<T>, noConfigurable?: boolean): void {
5
4
  if (!noConfigurable) descriptor.configurable = descriptor.enumerable = true
@@ -13,7 +12,7 @@ export function getDescriptor(object: IObject, name: string) {
13
12
  export function createDescriptor(key: string, defaultValue?: IValue) {
14
13
  const privateKey = '_' + key
15
14
  return {
16
- get() { const v = (this as IObject)[privateKey]; return isUndefined(v) ? defaultValue : v },
15
+ get() { const v = (this as IObject)[privateKey]; return v == null ? defaultValue : v },
17
16
  set(value: IValue) { (this as IObject)[privateKey] = value }
18
17
  }
19
18
  }