Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

md-slider Nullpointer in parseInt(computedStyle['min-width']) #8174

@IsNull

Description

@IsNull

Angular Material: 1.1.0-rc4
Browser: Safari, Firefox (probably not a Browser specific issue anyway)

How to reproduce

  1. Open Codepen: http://codepen.io/_IsNull/pen/GZBBvw
  2. Open Browser Developer Console
  3. Drag the slider around and observe a lot of errors

Details

Error: null is not an object (evaluating 'computedStyle')

ctrl.fitInputWidthToTextLength = function (length) {
          var input = element.find('md-input-container');
          var computedStyle = getComputedStyle(input[0]);
          var minWidth = parseInt(computedStyle['min-width']);
          var padding = parseInt(computedStyle['padding']) * 2;
          initialMaxWidth = initialMaxWidth || parseInt(computedStyle['max-width']);

          var newMaxWidth = Math.max(initialMaxWidth, minWidth + padding + (minWidth / 2 * length));

          input.css('max-width', newMaxWidth + 'px');
        };

So if computedStyle() can possibly return null, maybe add a check there.

Edit:
I am still trying to make it easily reproducible. It is happening in a (right) side nav, maybe dynamic layout calculations interfere with the md-slider layout logic.

Edit2:
Similar Error in Firefox:

Error: Argument 1 of Window.getComputedStyle is not an object.
postLink/ctrl.fitInputWidthToTextLength@
stepValidator/<@
timeout/timeoutId<@
completeOutstandingRequest@
Browser/self.defer/timeoutId<@

Metadata

Metadata

Assignees

Labels

has: Pull RequestA PR has been created to address this issueneeds: demoA CodePen demo or GitHub repository is needed to demonstrate the reproduction of the issue

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions