From d78cbed84de992ac473f2d3cccbc9c0eddf997c2 Mon Sep 17 00:00:00 2001 From: Fabien O'Carroll Date: Mon, 28 Oct 2019 16:30:16 +0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fixed=20error=20from=20has=20hel?= =?UTF-8?q?per=20w/o=20dependent=20data?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit no-issue Usage of the has helper like `{{#has 'author:count>1'}}` when the current context does not have the dependent data (in this case `authors`) would error, because it could not read property length of undefined. --- core/frontend/helpers/has.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/frontend/helpers/has.js b/core/frontend/helpers/has.js index 683c699557..a577d4d05b 100644 --- a/core/frontend/helpers/has.js +++ b/core/frontend/helpers/has.js @@ -11,6 +11,9 @@ var proxy = require('./proxy'), validAttrs = ['tag', 'author', 'slug', 'id', 'number', 'index', 'any', 'all']; function handleCount(ctxAttr, data) { + if (!data || !_.isFinite(data.length)) { + return false; + } let count; if (ctxAttr.match(/count:\d+/)) {