From e28ece72d025c99109bc2f9cfc75fefcbef0d94f Mon Sep 17 00:00:00 2001 From: Michael Prentice Date: Sun, 13 Sep 2020 04:51:44 -0400 Subject: [PATCH] fix(radio-button): Cannot read property 'nodeName' of null Fixes #10546 --- src/components/radioButton/radio-button.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/radioButton/radio-button.js b/src/components/radioButton/radio-button.js index 4e2abcacd9b..6b223aa991d 100644 --- a/src/components/radioButton/radio-button.js +++ b/src/components/radioButton/radio-button.js @@ -331,16 +331,17 @@ function mdRadioButtonDirective($mdAria, $mdUtil, $mdTheming) { } /** - * Add or remove the `.md-checked` class from the RadioButton (and conditionally its parent). - * Update the `aria-activedescendant` attribute. + * Add or remove the `.md-checked` class from the RadioButton (and conditionally its parent). + * Update the `aria-activedescendant` attribute. */ function render() { var checked = radioGroupController.getViewValue() == attr.value; if (checked === lastChecked) return; - if (element[0].parentNode.nodeName.toLowerCase() !== 'md-radio-group') { - // If the radioButton is inside a div, then add class so highlighting will work + if (element[0] && element[0].parentNode && + element[0].parentNode.nodeName.toLowerCase() !== 'md-radio-group') { + // If the radioButton is inside a div, then add class so highlighting will work. element.parent().toggleClass(CHECKED_CSS, checked); }