UNPKG

feature-u

Version:

Feature Based Project Organization for React

55 lines (41 loc) 1.73 kB
'use strict'; exports.__esModule = true; exports.default = assertNoRootAppElm; var _verify = require('../util/verify'); var _verify2 = _interopRequireDefault(_verify); var _lodash = require('lodash.isstring'); var _lodash2 = _interopRequireDefault(_lodash); var _logf = require('../util/logf'); var _logf2 = _interopRequireDefault(_logf); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * A convenience function that asserts the supplied `rootAppElm` is NOT * defined. * * When this constraint is not met, and error is thrown, after * emitting applicable context in the console log. * * For more information, please refer to * {{book.guide.injectingDomContent}}. * * @param {reactElm} rootAppElm the current react app element root to * check. * * @param {string} className the className on behalf of which this * assertion is performed. * * @function assertNoRootAppElm */ function assertNoRootAppElm(rootAppElm, className) { // validate parameters var check = _verify2.default.prefix('assertNoRootAppElm() parameter violation: '); // ... className check(className, 'className is required'); check((0, _lodash2.default)(className), 'className must be a string'); // perform assertion if (rootAppElm) { var msg = '***ERROR*** ' + className + ' does NOT support children ' + "but another feature/aspect is attempting to inject it's content. " + "Please resolve either by adjusting the feature expansion order, " + ('or promoting ' + className + ' through the conflicting artifact.'); _logf2.default.force(msg + ' ... conflicting artifact:', _logf2.default.elm2html(rootAppElm)); throw new Error(msg); } }