cst
Version:
JavaScript CST Implementation
86 lines (63 loc) • 3.01 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
var _Node2 = require('../Node');
var _Node3 = _interopRequireDefault(_Node2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// TODO: create JSXBoundaryElement?
var JSXOpeningElement = function (_Node) {
(0, _inherits3.default)(JSXOpeningElement, _Node);
function JSXOpeningElement(childNodes) {
(0, _classCallCheck3.default)(this, JSXOpeningElement);
return (0, _possibleConstructorReturn3.default)(this, (JSXOpeningElement.__proto__ || (0, _getPrototypeOf2.default)(JSXOpeningElement)).call(this, 'JSXOpeningElement', childNodes));
}
(0, _createClass3.default)(JSXOpeningElement, [{
key: '_acceptChildren',
value: function _acceptChildren(children) {
var attributes = [];
var selfClosing = false;
children.passToken('Punctuator', '<');
children.skipNonCode();
var name = children.passOneOfNode(['JSXIdentifier', 'JSXMemberExpression', 'JSXNamespacedName']);
children.skipNonCode();
while (true) {
if (children.isNode('JSXAttribute')) {
children.skipNonCode();
attributes.push(children.passNode('JSXAttribute'));
children.skipNonCode();
} else if (children.isNode('JSXSpreadAttribute')) {
children.skipNonCode();
attributes.push(children.passNode('JSXSpreadAttribute'));
children.skipNonCode();
} else {
break;
}
}
if (children.isToken('Punctuator', '/')) {
children.skipNonCode();
children.passToken('Punctuator', '/');
selfClosing = true;
children.skipNonCode();
}
children.passToken('Punctuator', '>');
children.assertEnd();
this.name = name;
this.attributes = attributes;
this.selfClosing = selfClosing;
}
}]);
return JSXOpeningElement;
}(_Node3.default);
exports.default = JSXOpeningElement;
//# sourceMappingURL=JSXOpeningElement.js.map