JSFiddle - React, Tailwind, and code Playground

by Viktor Zozulyak

HTML

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-data/3.0.0-rc.7/js-data.js"></script>
<div ng-app="myApp" ng-controller="myCtrl">
  <h2>Check console for errors</h2>
  
  <h3>Bug with JSData:</h3>
  binding JSData item directly - no errors.
  <my-component my-arg="jsDataItem"></my-component>
  binding JSData item as array - throws error <span class="error"> this._get is not a function</span>:
  <my-component my-arg="[jsDataItem]"></my-component>
   binding JSData item as property of object - throws error <span class="error"> this._get is not a function</span>:
  <my-component my-arg="{someProp: jsDataItem}"></my-component>
  
  <h3>Emulating the same bug with pure JS:</h3>
  binding an item directly - no errors.
  <my-component my-arg="item"></my-component>
  binding with item in array - throws error <span class="error">this._getter is not a function</span>:
  <my-component my-arg="[item]"></my-component>
    binding with item as property of object - throws error <span class="error">this._getter is not a function</span>:
  <my-component my-arg="{someProp: item}"></my-component>
</div>

CSS

my-component-array, my-component {
  display: block;
  margin-bottom: 15px;
}
.error {
  color: red;
}

JavaScript

const DS = new JSData.DataStore();

DS.defineMapper('Item', {
  schema: {
    properties: {
    	prop: {type: 'number'}
    }
  }
});

angular
  .module('myApp', [])
  .controller('myCtrl', ($scope) => {
    $scope.jsDataItem = DS.add('Item', {prop: 456});
    
    $scope.item = Object.create({
      	get prop() { return this._getter(); }
    });
		Object.defineProperty($scope.item, '_getter', {value: () => 123});
  })
  .component('myComponent', {
    bindings: {myArg: '<'}
  });