{"record":{"id":"5a1d5ee969a4d399","repo":"apache/hadoop","slug":"template-option-must-consist-of-exactly-1-top","errorCode":null,"errorMessage":"{} `template` option must consist of exactly 1 top-level element!","messagePattern":"(.+?) `template` option must consist of exactly 1 top-level element!","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/static/bootstrap-3.4.1/js/bootstrap.js","lineNumber":1873,"sourceCode":"    var o  = this.options\n\n    title = $e.attr('data-original-title')\n      || (typeof o.title == 'function' ? o.title.call($e[0]) :  o.title)\n\n    return title\n  }\n\n  Tooltip.prototype.getUID = function (prefix) {\n    do prefix += ~~(Math.random() * 1000000)\n    while (document.getElementById(prefix))\n    return prefix\n  }\n\n  Tooltip.prototype.tip = function () {\n    if (!this.$tip) {\n      this.$tip = $(this.options.template)\n      if (this.$tip.length != 1) {\n        throw new Error(this.type + ' `template` option must consist of exactly 1 top-level element!')\n      }\n    }\n    return this.$tip\n  }\n\n  Tooltip.prototype.arrow = function () {\n    return (this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow'))\n  }\n\n  Tooltip.prototype.enable = function () {\n    this.enabled = true\n  }\n\n  Tooltip.prototype.disable = function () {\n    this.enabled = false\n  }\n\n  Tooltip.prototype.toggleEnabled = function () {","sourceCodeStart":1855,"sourceCodeEnd":1891,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/static/bootstrap-3.4.1/js/bootstrap.js#L1855-L1891","documentation":"Tooltip.prototype.tip lazily builds the DOM node from options.template via $(this.options.template) and requires the resulting set to contain exactly one element: this.$tip.length != 1 throws this.type + ' `template` option must consist of exactly 1 top-level element!'. Templates with two or more top-level nodes, only text, or an empty string all fail.","triggerScenarios":"Overriding the tooltip/popover template with markup whose top level has 0 or 2+ elements — e.g. '<div>...</div><div>...</div>', a bare text fragment, or a template string built by concatenation that accidentally produces two roots or is empty.","commonSituations":"Custom-styled tooltips in HDFS web UI pages; dynamically generated template strings; trimming whitespace/markup in a way that drops the single root element.","solutions":["Keep exactly one root element: template: '<div class=\"tooltip\"><div class=\"tooltip-arrow\"></div><div class=\"tooltip-inner\"></div></div>'","Do not set template at all — the Bootstrap default already satisfies the single-root rule","When composing templates dynamically, wrap the output in a single <div> before assigning it"],"exampleFix":"// before\n$el.tooltip({template: '<div class=\"tooltip\"></div><div class=\"extra\"></div>'});\n\n// after\n$el.tooltip({template: '<div class=\"tooltip\"><div class=\"tooltip-arrow\"></div><div class=\"tooltip-inner\"></div></div>'});","handlingStrategy":"validation","validationCode":"var tpl = '<div class=\"tooltip\"><div class=\"tooltip-inner\"></div></div>';\nif ($(tpl).length !== 1) {\n  throw new Error('template must have exactly one root element');\n}\n$el.tooltip({template: tpl});","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep custom templates single-rooted","Omit template to use the tested Bootstrap default","When composing templates dynamically, wrap output in one <div>"],"tags":["javascript","bootstrap","tooltip","template","configuration"],"backgroundTag":"bootstrap-component-misconfiguration","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}