@canopycanopycanopy/b-ber-grammar-attributes 1.2.16 → 3.0.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.
Files changed (2) hide show
  1. package/dist/index.js +36 -34
  2. package/package.json +7 -6
package/dist/index.js CHANGED
@@ -40,15 +40,13 @@ var _lodash = _interopRequireDefault(require("lodash.has"));
40
40
 
41
41
  var _bBerLib = require("@canopycanopycanopy/b-ber-lib");
42
42
 
43
- var _utils = require("@canopycanopycanopy/b-ber-lib/utils");
44
-
45
43
  var _bBerLogger = _interopRequireDefault(require("@canopycanopycanopy/b-ber-logger"));
46
44
 
47
45
  var _bBerShapesDirectives = require("@canopycanopycanopy/b-ber-shapes-directives");
48
46
 
49
- function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); if (enumerableOnly) symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
47
+ function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
50
48
 
51
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context3; _forEachInstanceProperty(_context3 = ownKeys(Object(source), true)).call(_context3, function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { var _context4; _forEachInstanceProperty(_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
49
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context3 = ownKeys(Object(source), !0)).call(_context3, function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
52
50
 
53
51
  //
54
52
  // Querying hierarchies gets confusing, so we're using biological taxonomic
@@ -68,11 +66,11 @@ const _isUnsupportedAttribute = (genus, attr) => {
68
66
  let key;
69
67
 
70
68
  if (_bBerShapesDirectives.BLOCK_DIRECTIVES.has(genus)) {
71
- // these are all containers which share the same attributes, so they're
69
+ // These are all containers which share the same attributes, so they're
72
70
  // grouped under a single property
73
71
  key = 'block';
74
72
  } else {
75
- // this will be the directive name, e.g., figure, video, etc
73
+ // This will be the directive name, e.g., figure, video, etc
76
74
  key = genus;
77
75
  }
78
76
 
@@ -133,25 +131,25 @@ const parseAttrs = s => {
133
131
  if (!open && char === 58
134
132
  /* : */
135
133
  ) {
136
- // char is a token, we set `open` so that we don't misinterpret literals inside quotations
137
- open = true;
138
- key = str;
139
- str = '';
140
- delim = 32;
141
- /* */
142
-
143
- if (next === 34
144
- /* " */
145
- || next === 39
146
- /* ' */
147
- ) {
148
- i++;
149
- delim = next;
150
- }
151
-
152
- continue;
134
+ // char is a token, we set `open` so that we don't misinterpret literals inside quotations
135
+ open = true;
136
+ key = str;
137
+ str = '';
138
+ delim = 32;
139
+ /* */
140
+
141
+ if (next === 34
142
+ /* " */
143
+ || next === 39
144
+ /* ' */
145
+ ) {
146
+ i++;
147
+ delim = next;
153
148
  }
154
149
 
150
+ continue;
151
+ }
152
+
155
153
  if (char === delim) {
156
154
  // token is ending delimiter since we've advanced our pointer
157
155
  key = (0, _trim.default)(key).call(key); // trim whitespace, allowing for multiple spaces
@@ -246,13 +244,13 @@ const _extendWithDefaults = (obj, genus) => {
246
244
  }; // Create an object from attributes in the given directive
247
245
 
248
246
 
249
- const attributesObject = (attrs, _genus, context = {}) => {
247
+ const attributesObject = (attrs, origGenus, context = {}) => {
250
248
  const {
251
249
  fileName,
252
250
  lineNumber
253
251
  } = context;
254
252
  const attrsObject = {};
255
- let genus = _genus;
253
+ let genus = origGenus;
256
254
 
257
255
  if (!genus || typeof genus !== 'string') {
258
256
  _bBerLogger.default.error(`No directive provided: ${fileName}:${lineNumber}`);
@@ -275,23 +273,27 @@ const attributesObject = (attrs, _genus, context = {}) => {
275
273
  }
276
274
 
277
275
  if (attrs && typeof attrs === 'string') {
278
- (0, _utils.forOf)(parseAttrs((0, _trim.default)(attrs).call(attrs)), (k, v) => {
279
- if (_isUnsupportedAttribute(genus, k)) {
280
- return _bBerLogger.default.warn(`render omitting unsupported attribute [${k}] at [${fileName}:${lineNumber}]`);
276
+ const parsedAttrs = (0, _entries.default)(parseAttrs((0, _trim.default)(attrs).call(attrs))); // eslint-disable-next-line no-unused-vars
277
+
278
+ for (const [key, val] of parsedAttrs) {
279
+ if (_isUnsupportedAttribute(genus, key)) {
280
+ _bBerLogger.default.warn(`render omitting unsupported attribute [${key}] at [${fileName}:${lineNumber}]`);
281
+
282
+ continue;
281
283
  }
282
284
 
283
- attrsObject[k] = v;
284
- });
285
- } // Add original `_genus` as a class to the attrs object in case it's
285
+ attrsObject[key] = val;
286
+ }
287
+ } // Add original `origGenus` as a class to the attrs object in case it's
286
288
  // different from the current `genus` (which might've changed due to it's
287
289
  // specification). do this to keep styling consistent
288
290
 
289
291
 
290
- if (genus !== _genus) {
292
+ if (genus !== origGenus) {
291
293
  if ((0, _lodash.default)(attrsObject, 'classes')) {
292
- attrsObject.classes += ` ${_genus}`;
294
+ attrsObject.classes += ` ${origGenus}`;
293
295
  } else {
294
- attrsObject.classes = _genus;
296
+ attrsObject.classes = origGenus;
295
297
  }
296
298
  }
297
299
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canopycanopycanopy/b-ber-grammar-attributes",
3
- "version": "1.2.16",
3
+ "version": "3.0.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -17,9 +17,9 @@
17
17
  "access": "public"
18
18
  },
19
19
  "dependencies": {
20
- "@canopycanopycanopy/b-ber-lib": "1.2.16",
21
- "@canopycanopycanopy/b-ber-logger": "1.2.16",
22
- "@canopycanopycanopy/b-ber-shapes-directives": "1.2.16",
20
+ "@canopycanopycanopy/b-ber-lib": "3.0.0",
21
+ "@canopycanopycanopy/b-ber-logger": "3.0.0",
22
+ "@canopycanopycanopy/b-ber-shapes-directives": "3.0.0",
23
23
  "lodash": "^4.17.21",
24
24
  "lodash.has": "latest",
25
25
  "tar": "^6.1.11"
@@ -28,8 +28,9 @@
28
28
  "@babel/cli": "^7.10.5",
29
29
  "@babel/core": "^7.10.5",
30
30
  "@babel/preset-env": "^7.10.4",
31
+ "browserslist": "^4.17.4",
31
32
  "jest": "^26.6.3",
32
- "rimraf": "^2.6.3"
33
+ "rimraf": "^2.7.1"
33
34
  },
34
35
  "files": [
35
36
  "dist"
@@ -48,5 +49,5 @@
48
49
  "url": "https://maxwellsimmer.com"
49
50
  }
50
51
  ],
51
- "gitHead": "b4d9c563beb349a32c19e0f65447f7c7dbc8ea52"
52
+ "gitHead": "676dbec7fbdcc46eb8168f1d437d294ed549e2e8"
52
53
  }