lightning-js / blits

The Lightning 3 App Development Framework
Apache License 2.0
58 stars 9 forks source link

Fixed issue with dynamic arguments in object #90

Open suresh-gangumalla opened 2 months ago

suresh-gangumalla commented 2 months ago

Resolved issue with dealing dyanmic arguments in an object that has assiged to attribute. This issue is mainly occurs with mount, pivot and color attribute when object litteral is assigned as value with dynamic arguments.

Code generator now able to correctly link dynamic values for above code snippet. It will output,

elementConfig1['color'] = { top: component.colorT, bottom: component.colorB, left: component.colorL} elementConfig1['mount'] = { x: component.mX, y: component.mY }

suresh-gangumalla commented 2 months ago

@uguraslan

I have updated key specific regular expressions into a generic expression.

The generic regular expression is /\w+\s*:\s*(?:[^\s,}]+|".*?"|'.*?')/g ,

Sample input object with dynamic values and static value

  1.  "{x: $mX, y: 1}".match(regEx) results to ['x: $mX', 'y: 1']
  2. "{x: $mX, y: $mY}".match(regEx) results to ['x: $mX', 'y: $mY']
  3. "{top: '0xff0000ff', bottom: $colorB, left:$colorL, right: $colorR}" results to["top: '0xff0000ff'", 'bottom: $colorB', 'left:$colorL', 'right: $colorR']