Fix 'document' compatibility in node