sproutjs-core 2.6.0 → 2.7.1

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": "sproutjs-core",
3
- "version": "2.6.0",
3
+ "version": "2.7.1",
4
4
  "keywords": [],
5
5
  "author": "",
6
6
  "license": "ISC",
package/sprout-core.js CHANGED
@@ -678,11 +678,13 @@ var COMMANDS = {
678
678
  theState._stateManager.addStateMap(stateItemsPropertyName, customElementName, thiselement);
679
679
  });
680
680
  },
681
- text: function text(commandValue) {
682
- var stateProp = commandValue;
683
- this.initialSetText(stateProp);
684
- // DO NOT CALL .normalize()! It might change the Text Nodes!
681
+ /*
682
+ text: function(commandValue) {
683
+ const stateProp = commandValue;
684
+ this.initialSetText(stateProp);
685
+ // DO NOT CALL .normalize()! It might change the Text Nodes!
685
686
  },
687
+ */
686
688
  bind: function bind(commandValue) {
687
689
  if (true) {
688
690
  if (this.tagName !== "INPUT") {
@@ -725,12 +727,6 @@ var COMMANDS = {
725
727
  }
726
728
  };
727
729
  ;// ./src/shared/parse_utils.js
728
- function parse_utils_toConsumableArray(r) { return parse_utils_arrayWithoutHoles(r) || parse_utils_iterableToArray(r) || parse_utils_unsupportedIterableToArray(r) || parse_utils_nonIterableSpread(); }
729
- function parse_utils_nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
730
- function parse_utils_unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return parse_utils_arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? parse_utils_arrayLikeToArray(r, a) : void 0; } }
731
- function parse_utils_iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
732
- function parse_utils_arrayWithoutHoles(r) { if (Array.isArray(r)) return parse_utils_arrayLikeToArray(r); }
733
- function parse_utils_arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
734
730
  /* Possible expression:
735
731
  * literal: straight state prop,.
736
732
  * negation: !something (not something)
@@ -738,8 +734,11 @@ function parse_utils_arrayLikeToArray(r, a) { (null == a || a > r.length) && (a
738
734
  * ternary: somethingIsTruthy?returnThis:[elseThis]
739
735
  */
740
736
  function parseStateExpression(expression) {
737
+ if (expression.indexOf('@') === 0) {
738
+ return ["property", [expression.substring(1)]];
739
+ }
741
740
  if (expression.indexOf('!') === 0) {
742
- return ["negation", expression.substring(1)];
741
+ return ["negation", [expression.substring(1)]];
743
742
  }
744
743
  var charIndex = 0;
745
744
  var parsed = expression[charIndex];
@@ -747,14 +746,14 @@ function parseStateExpression(expression) {
747
746
  while (charIndex++ < expression.length) {
748
747
  _char = expression[charIndex];
749
748
  if (charIndex == 3 && parsed == "is_") {
750
- return ["equality"].concat(parse_utils_toConsumableArray(expression.substring(3).split(':')));
749
+ return ["equality", expression.substring(3).split(':')];
751
750
  }
752
751
  if (_char === '?') {
753
- return ["ternary", parsed].concat(parse_utils_toConsumableArray(expression.substring(charIndex + 1).split(':')));
752
+ return ["ternary", parsed, expression.substring(charIndex + 1).split(':')];
754
753
  }
755
754
  parsed += _char;
756
755
  }
757
- return ["literal", expression];
756
+ return ["literal", [expression]];
758
757
  }
759
758
  function fromAttributeValue(value) {
760
759
  if (value === '') return true;
@@ -903,11 +902,19 @@ function extendElementClassWithReactiveElementClass(elementClass) {
903
902
  // getRootNode - returns shadowRoot if this is inside shadow DOM, and document if it's in light DOM.
904
903
  var rootNode = this.getRootNode();
905
904
 
906
- // If this is inside light DOM - we take the direct parent,
905
+ // If this is inside light DOM and the parent is a Sprout custom element - we take the direct parent,
907
906
  // this works e.g. with a light element with "slot" attribute, inside a Sprout component
908
907
  // (It will have access to its "state")
909
908
 
910
- this.host = rootNode === document ? this.parentElement : rootNode.host;
909
+ if (rootNode !== document) {
910
+ this.host = rootNode.host;
911
+ } else if (isReactiveCustomElement(this.parentElement)) {
912
+ this.host = this.parentElement;
913
+ } else {
914
+ // This could mean this is actually a top-level Sprout Custom Element ("host"),
915
+ // i.e. a custom element that is not inside shadowDOM
916
+ roost.host = null;
917
+ }
911
918
  if (this.host) {
912
919
  // Once the host custom element is connected
913
920
  // then its 'State' is ready and activated,
@@ -1040,7 +1047,11 @@ function extendElementClassWithReactiveElementClass(elementClass) {
1040
1047
  }
1041
1048
  var stateProp = attributeValue;
1042
1049
  var attrName = attributeName.substring(1);
1043
- setStateAttribute.call(this, attrName, stateProp);
1050
+ if (attrName === "textContent") {
1051
+ this.initialSetText(stateProp);
1052
+ } else {
1053
+ setStateAttribute.call(this, attrName, stateProp);
1054
+ }
1044
1055
  } else {
1045
1056
  if (isPropAttr) {
1046
1057
  var host = this.getHost();
@@ -1053,7 +1064,11 @@ function extendElementClassWithReactiveElementClass(elementClass) {
1053
1064
  var propValue = host.getAttribute(propName);
1054
1065
  valueToSet = propValue;
1055
1066
  }
1056
- setAttribute.call(this, attributeName, valueToSet);
1067
+ if (attributeName === "textContent") {
1068
+ this.initialSetText(valueToSet);
1069
+ } else {
1070
+ setAttribute.call(this, attributeName, valueToSet);
1071
+ }
1057
1072
  }
1058
1073
  }
1059
1074
  }, {