sproutjs-core 2.6.0 → 2.7.0
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 +1 -1
- package/sprout-core.js +39 -24
- package/sprout-core.js.map +1 -1
- package/sprout-core.min.js +1 -1
- package/sprout-core.min.js.map +1 -1
- package/sprout-core.strict.js +17 -38
- package/sprout-core.strict.js.map +1 -1
- package/sprout-core.strict.min.js +1 -1
- package/sprout-core.strict.min.js.map +1 -1
package/package.json
CHANGED
package/sprout-core.js
CHANGED
|
@@ -678,11 +678,13 @@ var COMMANDS = {
|
|
|
678
678
|
theState._stateManager.addStateMap(stateItemsPropertyName, customElementName, thiselement);
|
|
679
679
|
});
|
|
680
680
|
},
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
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"
|
|
749
|
+
return ["equality", expression.substring(3).split(':')];
|
|
751
750
|
}
|
|
752
751
|
if (_char === '?') {
|
|
753
|
-
return ["ternary", parsed
|
|
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;
|
|
@@ -846,14 +845,14 @@ function extendElementClassWithReactiveElementClass(elementClass) {
|
|
|
846
845
|
_step;
|
|
847
846
|
try {
|
|
848
847
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
849
|
-
var
|
|
850
|
-
var attrValue = this.getAttribute(
|
|
848
|
+
var _attrName = _step.value;
|
|
849
|
+
var attrValue = this.getAttribute(_attrName);
|
|
851
850
|
// This also resolves "State attributes"
|
|
852
|
-
this.initialSetAttribute(
|
|
851
|
+
this.initialSetAttribute(_attrName, attrValue);
|
|
853
852
|
|
|
854
853
|
// Save "Command attributes"
|
|
855
|
-
if (
|
|
856
|
-
var command =
|
|
854
|
+
if (_attrName.indexOf('_') === 0) {
|
|
855
|
+
var command = _attrName.substring(1);
|
|
857
856
|
commands.push({
|
|
858
857
|
command: command,
|
|
859
858
|
args: attrValue
|
|
@@ -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
|
-
|
|
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,
|
|
@@ -1039,8 +1046,12 @@ function extendElementClassWithReactiveElementClass(elementClass) {
|
|
|
1039
1046
|
}
|
|
1040
1047
|
}
|
|
1041
1048
|
var stateProp = attributeValue;
|
|
1042
|
-
var
|
|
1043
|
-
|
|
1049
|
+
var _attrName2 = attributeName.substring(1);
|
|
1050
|
+
if (_attrName2 === "textContent") {
|
|
1051
|
+
this.initialSetText(stateProp);
|
|
1052
|
+
} else {
|
|
1053
|
+
setStateAttribute.call(this, _attrName2, 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
|
-
|
|
1067
|
+
if (attrName === "textContent") {
|
|
1068
|
+
this.initialSetText(valueToSet);
|
|
1069
|
+
} else {
|
|
1070
|
+
setAttribute.call(this, attributeName, valueToSet);
|
|
1071
|
+
}
|
|
1057
1072
|
}
|
|
1058
1073
|
}
|
|
1059
1074
|
}, {
|