Attr: Use typeof check for getAttribute method

Ref 29838b6cab6f2e508f3e9692f32918c72b1a504b