Permalink
Browse files

Merge pull request #527 from koenbok/feature/textlayer-state

Feature/textlayer state
  • Loading branch information...
nvh committed Jul 12, 2017
2 parents 0697f93 + ad2f680 commit b0ae258c28b88782ca299e881f61f6ce3af963e9
View
@@ -24,7 +24,7 @@ class exports.BaseClass extends EventEmitter
if @ isnt BaseClass
@_addDescriptor(propertyName, descriptor)
if not descriptor.set?
if descriptor.readonly
descriptor.set = (value) ->
throw Error("#{@constructor.name}.#{propertyName} is readonly")
@@ -43,20 +43,20 @@ class exports.BaseClass extends EventEmitter
descriptor.enumerable ?= true
descriptor.exportable ?= true
descriptor.importable ?= true
descriptor.readonly ?= not descriptor.set?
# We assume we don't import if there is no setter, because we can't
descriptor.importable = descriptor.importable and descriptor.set?
descriptor.importable = descriptor.importable and not descriptor.readonly
# We also assume we don't export if there is no setter, because
# it is likely a calculated property, and we can't set it.
descriptor.exportable = descriptor.exportable and descriptor.set?
descriptor.exportable = descriptor.exportable and not descriptor.readonly
# We assume that every property with an underscore is private
return if _.startsWith(propertyName, "_")
ObjectDescriptors.push([@, propertyName, descriptor])
# Only retain options that are importable, exportable or both:
if descriptor.exportable or descriptor.importable
ObjectDescriptors.push([@, propertyName, descriptor])
if descriptor.depends
for depend in descriptor.depends
if depend not in DefaultPropertyOrder
@@ -102,8 +102,12 @@ class exports.BaseClass extends EventEmitter
_propertyList: ->
result = {}
for k in ObjectDescriptors
if @ instanceof k[0]
result[k[1]] = k[2]
[Class, name, descriptor] = k
if @ instanceof Class
if descriptor.exportable or descriptor.importable
result[name] = descriptor
else
delete result[name]
return result
keys: -> _.keys(@props)
@@ -178,7 +182,7 @@ class exports.BaseClass extends EventEmitter
# the value from the options object, unless the prop is not importable.
# When there's no user value, apply the default value:
return unless descriptor.set?
return if descriptor.readonly
value = optionValue if descriptor.importable
value = Utils.valueOrDefault(optionValue, @_getPropertyDefaultValue(key))
@@ -4,7 +4,7 @@
{BaseClass} = require "./BaseClass"
{Defaults} = require "./Defaults"
{LayerStateMachine} = require "./LayerStateMachine"
{StyledText} = require "./StyledText"
LayerStatesIgnoredKeys = ["ignoreEvents", "name", "id"]
reservedStateError = (name) ->
@@ -61,11 +61,14 @@ class LayerStates
if Color.isValidColorProperty(k, v)
stateProperties[k] = new Color(v)
continue
if Gradient.isGradient(v)
stateProperties[k] = v
continue
if StyledText.isStyledText(v)
stateProperties[k] = v
if @_isValidProperty(k, v)
stateProperties[k] = v
Oops, something went wrong.

0 comments on commit b0ae258

Please sign in to comment.