{"@attributes":{"version":"2.0"},"channel":{"title":"DEV Community: vinay kumar","description":"The latest articles on DEV Community by vinay kumar (@vinaymcscet).","link":"https:\/\/dev.to\/vinaymcscet","image":{"url":"https:\/\/media2.dev.to\/dynamic\/image\/width=90,height=90,fit=cover,gravity=auto,format=auto\/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F531274%2F4c99468f-4e55-4890-b3a5-cc7ff6f699c4.jpeg","title":"DEV Community: vinay kumar","link":"https:\/\/dev.to\/vinaymcscet"},"language":"en","item":[{"title":"write testcases for the below functions in Angular TypeScript using Jasmin-karma.","pubDate":"Mon, 12 Jul 2021 06:03:49 +0000","link":"https:\/\/dev.to\/vinaymcscet\/write-testcases-for-the-below-functions-in-angular-typescript-using-jasmin-karma-14gm","guid":"https:\/\/dev.to\/vinaymcscet\/write-testcases-for-the-below-functions-in-angular-typescript-using-jasmin-karma-14gm","description":"<p>open(): void {<br>\n    this.isActivate = true;<br>\n    document.body.appendChild(this.element);<br>\n    this.element.style.display = 'block';<br>\n    document.body.classList.add('tfb-modal-open', 'body--no-scroll');<br>\n    setTimeout(() =&gt; {<br>\n      const focusableElements =<br>\n        'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])';<br>\n      const modal = document.querySelector('#tfb-modal'); \/\/ select the modal by it's id<br>\n      console.log(\"modal\", modal);<\/p>\n\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>  const firstFocusableElement = modal.querySelectorAll(focusableElements)[0] as HTMLInputElement;\n  console.log(\"firstFocusableElement\", firstFocusableElement);\n  \/\/ get first element to be focused inside modal\n  const focusableContent = modal.querySelectorAll(focusableElements);\n  console.log(\"focusableContent\", focusableContent);\n  let lastFocusableElement: any;\n  if (focusableContent.length &lt;= 2) {\n    lastFocusableElement = focusableContent[focusableContent.length - 2] as HTMLInputElement;\n    console.log(\"lastFocusableElement_if\", lastFocusableElement);\n     \/\/ get last element to be focused inside modal\n  } else {\n    lastFocusableElement = focusableContent[focusableContent.length - 1] as HTMLInputElement;\n    console.log(\"lastFocusableElement_else\", lastFocusableElement);\n     \/\/ get last element to be focused inside modal\n  }\n\n  document.addEventListener('keydown', (e) =&gt; {\n    \/\/ tslint:disable-next-line: deprecation\n    const isTabPressed = e.key === 'Tab' || e.keyCode === 9;\n    if (!isTabPressed) {\n      return;\n    }\n    if (e.shiftKey) { \/\/ if shift key pressed for shift + tab combination\n      if (document.activeElement === firstFocusableElement) {\n        lastFocusableElement.focus(); \/\/ add focus for the last focusable element\n        e.preventDefault();\n      }\n    } else { \/\/ if tab key is pressed\n      if (document.activeElement === lastFocusableElement) {\n        \/\/ if focused has reached to last focusable element then focus first focusable\n        \/\/ element after pressing tab\n        firstFocusableElement.focus(); \/\/ add focus for the first focusable element\n        e.preventDefault();\n      }\n    }\n  });\n\n  firstFocusableElement.focus();\n}, (1000));\n<\/code><\/pre>\n\n<\/div>\n\n<p>}<\/p>\n\n"},{"title":"Hacktober Badge","pubDate":"Fri, 04 Dec 2020 06:39:23 +0000","link":"https:\/\/dev.to\/vinaymcscet\/hacktober-badge-4h0e","guid":"https:\/\/dev.to\/vinaymcscet\/hacktober-badge-4h0e","description":"<p>Hi,<br>\nI am very much pretty excited to receive my first Hacktober Fest Badge.<\/p>\n\n"}]}}