Transition is not working properly in Safari

So I’ve made a custom cursor for my next website. In Chrome it works as it should but in Safari it’s laggy…

I’ve tried several things like using the webkit stuff but it still doesn’t work.

here is the Codepen

html

<div class="cursor"></div>

css

body{
  background: #fff;
  width: 100%;
  height: 100vh;
}
.cursor{
    position: fixed;
    left: 0px;
    top: 0;
    width: 25px;
    height: 25px;

    transition-duration:0.3s;
    -webkit-transition-duration:0.3s;
    -ms-transition-duration:0.3s;
    -moz-transition-duration:0.3s;

    transition-timing-function: cubic-bezier(.33,.81,.66,.95);
    -webkit-transition-timing-function: cubic-bezier(.33,.81,.66,.95);
    -moz-transition-timing-function: cubic-bezier(.33,.81,.66,.95);
    background-color: #fff;
    mix-blend-mode: difference;
    border-radius: 50%;
    pointer-events: none;
}

js

let cursor = document.querySelector('.cursor');
document.addEventListener('mousemove', moveCursor);

function moveCursor(e) {
    let x = e.clientX;
    let y = e.clientY;

    cursor.style.transform = `translate(calc(${x}px - 50%), calc(${y}px - 50%))`
}

Isotope.js not filtering correctly when using checkboxes

I have a simple filter which contains two checkboxes, one for cake another for cupcake.

A user can check either option, or select both to show all results. However, even though my filters array contains the correct values, nothing shows.

Even when filtering by one option, it doesn’t showcase the correct results.

See demo here:

(function($) {

  var $grid = $('.shop__grid'),
    $checkboxes = $('.isotope-trigger');

  $grid.isotope({
    itemSelector: '.productCard',
    layoutMode: 'fitRows'
  });

  $grid.imagesLoaded().progress(function() {
    $grid.isotope('layout');
  });


  $checkboxes.change(function() {
    var filters = [];
    // get checked checkboxes values
    $checkboxes.filter(':checked').each(function() {
      filters.push(this.value);
    });
    // filters = filters.join(', ');
    $grid.isotope({
      filter: filters
    });
    console.log(filters);
  });


})(jQuery);
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js" integrity="sha512-894YE6QWD5I59HgZOGReFYm4dnWc1Qt5NtvYSaNcOP+u1T9qYdvdihz0PPSiiqn/+/3e7Jo4EaG7TubfWGUrMQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://unpkg.com/isotope-layout@3/dist/isotope.pkgd.min.js"></script>
<script src="https://unpkg.com/imagesloaded@5/imagesloaded.pkgd.min.js"></script>

<div class="shop">
  <div class="container">
    <div class="row">

      <!-- filter -->
      <div class="col-12 col-md-3">
        <div class="shopFilter">
          <div class="shopFilter__category">
            <span class="shopFilter__category-label d-block">Type</span>
            <div class="shopFilter__category-options">
              <div class="filterOption">
                <input class="filterOption__input isotope-trigger" type="checkbox" data-filter=".cake" name="item-cake" value="Cake" id="cake">
                <label class="filterOption__label" for="item-cake">Cake</label>
              </div>
              <div class="filterOption">
                <input class="filterOption__input isotope-trigger" type="checkbox" data-filter=".cupcake" name="item-cupcake" value="Cupcake" id="cupcake">
                <label class="filterOption__label" for="item-cupcake">Cupcake</label>
              </div>
            </div>
          </div>
        </div>
      </div>

      <!-- listing -->
      <div class="col-12 col-md-7">
        <div class="shop__grid">
          <div class="productCard text-center cake">Cake</div>
          <div class="productCard text-center cake">Cake</div>
          <div class="productCard text-center cupcake">Cupcake</div>
          <div class="productCard text-center cake">Cake</div>
        </div>
      </div>
      <!---->

    </div>
  </div>
</div>

Wrong count execution times of Sinon Spy

I have a major function that call 3 other functions. I want to test if those 3 function were called.

myController.ts

import axios from 'axios';

export async function functionOne() {
  console.log('Hit functionOne');
  const result = await axios.get('https://www.urlOne.com/first');
  return result;
}

export async function functionTwo() {
  const result = await axios.get('https://www.urlTwo.com/second');
  return result;
}

export async function functionThree() {
  const result = await axios.get('https://www.urlThree.com/third');
  return result;
}

export async function mainFunction() {
  const resultOne = await functionOne();
  // some logic that also calls functionTwo & functionThree
}



test.spec.ts

import * as myCtrl from '../controllers';
import { expect } from 'chai';
import * as sinon from 'sinon';
import * as sinonChai from 'sinon-chai';
import * as chaiAsPromised from 'chai-as-promised';

chai.use(sinonChai);
chai.use(chaiAsPromised);
chai.should();

describe('success', () => {
  const sandbox = sinon.createSandbox();

  // Create Spies
  beforeEach(() => {
    sandbox.spy(myCtrl, 'functionOne');
    sandbox.spy(myCtrl, 'functionTwo');
    sandbox.spy(myCtrl, 'functionThree');
  });

  afterEach(() => {
    sandbox.restore();
  })


  it('test something', async () => {
    nock('https://www.urlOne.com')
      .get('first')
      .reply(200)

    nock('https://www.urlTwo.com')
      .get('second')
      .reply(200)

    nock('https://www.urlThree.com')
      .get('third')
      .reply(200)

    await myCtrl.mainFunction();

    expect(myCtrl.functionOne).to.be.calledOnce();
    expect(myCtrl.functionTwo).to.be.calledOnce();
    expect(myCtrl.functionThree).to.be.calledOnce();
  });
});

It looks weird, but according to the nock documentation, using multiple nocks is the right way.

The problem is, it always returns:

AssertionError: expected functionOne to have been called exactly once, but it was called 0 times

I can see the console.log message on console, but the count still 0. Am I missing something here?

Should I be using jQuery? what is the jQuery replacement?

I start my IT career in sysOps and new to web development. I’m looking at a code that someone wrote previously that is using jQuery to interact with DOM. After doing some research I’m seeing people still using jQuery vs “jQuery is old” crowd. As a person new to web development, should I be learning jQuery or move on to the new alternative? and what is the new alternative that can be marketable in the web development career.

React state not consistent when using delay

I have a component with another component inside it that I only want to show if the user is still hovering after a short delay.

So I wrote a couple handlers for onMouseEnter and onMouseExit to set a variable to show that its hovered. Then, after sleeping, if it’s still hovered I want to set a second variable to show the element.

However, hovered is showing as false no matter what. Why?

    const [hovered, setHovered] = useState(false);
    const [show, setShow] = useState(false);

    console.log('hovered', hovered); // This shows the state correctly

    const handleEnter = () => {
        setHovered(true);
        sleep(2000).then(() => {
            console.log('checking', hovered); // This always shows false
            if (hovered) {
                setShow(true);
            }
        });
    }

    const handleExit = () => {
        setHovered(false);
        setShow(false);
    }

How to click on a button(no Id in tag) in html page after 5 seconds when page is loaded

A boog noob Alert!…I’ve html div like this

<div class="col mt-2">
<button @click="selected = Array.from(header); render()" class="btn btn-light-alt btn-sm">Select all</button>
<button @click="selected = []" class="btn btn-light-alt btn-sm">Clear selection</button></div>
    

All I want to do is click on this Select all button after 5 seconds webpage is loaded. I’ve searched for this way to do it & I found this

setTimeout(document.getElementByID('button').click(),5000);

I think button is Id here???…But there is no Id in my html tag…we can see only class is available…so can I achieve this requirement?…Any similar threads that you guys know?

Can’t install any other libraries anymore in node_modules, evertime I got the same error while install libraries

0 verbose cli C:Program Filesnodejsnode.exe C:UsersJenisAppDataRoamingnpmnode_modulesnpmbinnpm-cli.js

1 info using [email protected]

2 info using [email protected]

3 timing npm:load:whichnode Completed in 0ms

4 timing config:load:defaults Completed in 1ms

5 timing config:load:file:C:UsersJenisAppDataRoamingnpmnode_modulesnpmnpmrc Completed in 2ms

6 timing config:load:builtin Completed in 2ms

7 timing config:load:cli Completed in 1ms

8 timing config:load:env Completed in 0ms

9 timing
config:load:file:C:UsersJenisOneDriveDocumentsFinal_Year_ProjectThe_appThe_restaurant
_app.npmrc Completed in 0ms

10 timing config:load:project Completed in 2ms

11 timing config:load:file:C:UsersJenis.npmrc Completed in 0ms

12 timing config:load:user Completed in 0ms

13 timing config:load:file:C:UsersJenisAppDataRoamingnpmetcnpmrc Completed in 0ms

14 timing config:load:global Completed in 0ms

15 timing config:load:validate Completed in 0ms

16 timing config:load:credentials Completed in 1ms

17 timing config:load:setEnvs Completed in 0ms

18 timing config:load Completed in 7ms

19 timing npm:load:configload Completed in 7ms

20 timing npm:load:mkdirpcache Completed in 1ms

21 timing npm:load:mkdirplogs Completed in 0ms

22 verbose title npm install @twotalltotems/react-native-otp-input

23 verbose argv “install” “–save” “@twotalltotems/react-native-otp-input”

24 timing npm:load:setTitle Completed in 1ms

25 timing config:load:flatten Completed in 1ms

26 timing npm:load:display Completed in 2ms

27 verbose logfile logs-max:10 dir:C:UsersJenisAppDataLocalnpm-cache_logs

28 verbose logfile C:UsersJenisAppDataLocalnpm-cache_logs2022-07-08T19_46_57_590Z-
debug-0.log

29 timing npm:load:logFile Completed in 3ms

30 timing npm:load:timers Completed in 0ms

31 timing npm:load:configScope Completed in 0ms

32 timing npm:load Completed in 14ms

33 timing arborist:ctor Completed in 0ms

34 silly logfile start cleaning logs, removing 2 files

35 silly logfile done cleaning log files

36 verbose shrinkwrap failed to load node_modules/.package-lock.json out of date, updated:
node_modules

37 timing idealTree:init Completed in 1107ms

38 timing idealTree:userRequests Completed in 4ms

39 silly idealTree buildDeps

40 silly fetch manifest @twotalltotems/react-native-otp-input@*

41 http fetch GET 200 https://registry.npmjs.org/@twotalltotems%2freact-native-otp-input
472ms (cache hit)

42 silly placeDep ROOT @twotalltotems/[email protected] OK for:
[email protected] want: *

43 silly fetch manifest @react-native-community/clipboard@^1.2.2

44 http fetch GET 200 https://registry.npmjs.org/@react-native-community%2fclipboard 762ms
(cache hit)

45 timing idealTree:#root Completed in 1243ms

46 silly fetch manifest react@>=16.0

47 http fetch GET 200 https://registry.npmjs.org/react 21ms (cache hit)

48 silly fetch manifest react-native@>=0.57.0

49 http fetch GET 200 https://registry.npmjs.org/react-native 7ms (cache hit)

50 silly fetch manifest [email protected]

51 silly placeDep ROOT @react-native-community/[email protected] OK for: @twotalltotems/react-
[email protected] want: ^1.2.2

52 timing idealTree:node_modules/@twotalltotems/react-native-otp-input Completed in 50ms

53 timing idealTree:node_modules/@react-native-community/clipboard Completed in 0ms

54 silly fetch manifest react-native-safe-area-context@^3.1.9

55 http fetch GET 200 https://registry.npmjs.org/react-native-safe-area-context 7ms (cache
hit)

56 silly fetch manifest react@*

57 silly fetch manifest react-native@*

58 timing idealTree Completed in 2420ms

59 timing command:install Completed in 2427ms

60 verbose stack Error: could not resolve

60 verbose stack at PlaceDep.failPeerConflict
(C:UsersJenisAppDataRoamingnpmnode_modulesnpmnode_modules@npmcliarboristlibplace
-dep.js:549:25)

60 verbose stack at PlaceDep.place
(C:UsersJenisAppDataRoamingnpmnode_modulesnpmnode_modules@npmcliarboristlibplace
-dep.js:199:21)

60 verbose stack at new PlaceDep
(C:UsersJenisAppDataRoamingnpmnode_modulesnpmnode_modules@npmcliarboristlibplace
-dep.js:73:10)

60 verbose stack at
C:UsersJenisAppDataRoamingnpmnode_modulesnpmnode_modules@npmcliarboristlibarbori
stbuild-ideal-tree.js:990:31

60 verbose stack at Array.map ()

60 verbose stack at Arborist.[buildDepStep]
(C:UsersJenisAppDataRoamingnpmnode_modulesnpmnode_modules@npmcliarboristlibarbor
istbuild-ideal-tree.js:990:8)

60 verbose stack at async Arborist.buildIdealTree
(C:UsersJenisAppDataRoamingnpmnode_modulesnpmnode_modules@npmcliarboristlibarbor
istbuild-ideal-tree.js:218:7)

60 verbose stack at async Promise.all (index 1)

60 verbose stack at async Arborist.reify
(C:UsersJenisAppDataRoamingnpmnode_modulesnpmnode_modules@npmcliarboristlibarbor
istreify.js:153:5)

60 verbose stack at async Install.exec
(C:UsersJenisAppDataRoamingnpmnode_modulesnpmlibcommandsinstall.js:145:5)

60 verbose stack at async module.exports
(C:UsersJenisAppDataRoamingnpmnode_modulesnpmlibcli.js:78:5)

61 verbose cwd
C:UsersJenisOneDriveDocumentsFinal_Year_ProjectThe_appThe_restaurant_app

62 verbose Windows_NT 10.0.22000

63 verbose node v16.16.0

64 verbose npm v8.13.2
65 error code ERESOLVE

66 error ERESOLVE could not resolve

67 error

68 error While resolving: [1mreact-native-elements[22m@[1m3.4.2[22m

68 error Found: [1mreact-native-safe-area-context[22m@[1m4.2.4[22m[2m[22m

68 error [2mnode_modules/react-native-safe-area-context[22m

68 error [35mpeer[39m [1mreact-native-safe-area-context[22m@”[1m>= 3.0.0[22m” from
[1m@react-navigation/bottom-tabs[22m@[1m6.3.1[22m[2m[22m

68 error [2mnode_modules/@react-navigation/bottom-tabs[22m

68 error [1m@react-navigation/bottom-tabs[22m@”[1m^6.3.1[22m” from the root project

68 error [35mpeer[39m [1mreact-native-safe-area-context[22m@”[1m>= 3.0.0[22m” from
[1m@react-navigation/elements[22m@[1m1.3.3[22m[2m[22m

68 error [2mnode_modules/@react-navigation/elements[22m

68 error [1m@react-navigation/elements[22m@”[1m^1.3.3[22m” from [1m@react-
navigation/bottom-tabs[22m@[1m6.3.1[22m[2m[22m

68 error [2mnode_modules/@react-navigation/bottom-tabs[22m

68 error [1m@react-navigation/bottom-tabs[22m@”[1m^6.3.1[22m” from the root
project

68 error [1m@react-navigation/elements[22m@”[1m^1.3.3[22m” from [1m@react-
navigation/stack[22m@[1m6.2.1[22m[2m[22m

68 error [2mnode_modules/@react-navigation/stack[22m

68 error [1m@react-navigation/stack[22m@”[1m^6.2.1[22m” from the root project

68 error 4 more (@react-navigation/stack, native-base, …)

68 error

68 error Could not resolve dependency:

68 error [35mpeer[39m [1mreact-native-safe-area-context[22m@”[1m^3.1.9[22m” from
[1mreact-native-elements[22m@[1m3.4.2[22m[2m[22m

68 error [2mnode_modules/react-native-elements[22m

68 error [1mreact-native-elements[22m@”[1m^3.4.2[22m” from the root project

68 error

68 error Conflicting peer dependency: [1mreact-native-safe-area-
context[22m@[1m3.4.1[22m[2m[22m

68 error [2mnode_modules/react-native-safe-area-context[22m

68 error [35mpeer[39m [1mreact-native-safe-area-context[22m@”[1m^3.1.9[22m” from
[1mreact-native-elements[22m@[1m3.4.2[22m[2m[22m

68 error [2mnode_modules/react-native-elements[22m

68 error [1mreact-native-elements[22m@”[1m^3.4.2[22m” from the root project

68 error

68 error Fix the upstream dependency conflict, or retry

68 error this command with –force, or –legacy-peer-deps

68 error to accept an incorrect (and potentially broken) dependency resolution.

68 error

68 error See C:UsersJenisAppDataLocalnpm-cacheeresolve-report.txt for a full report.

69 verbose exit 1

70 timing npm Completed in 2513ms

71 verbose unfinished npm timer reify 1657309617667

72 verbose unfinished npm timer reify:loadTrees 1657309617672

73 verbose unfinished npm timer idealTree:buildDeps 1657309618783

74 verbose unfinished npm timer idealTree:node_modules/react-native-elements 1657309620076

75 verbose code 1

76 error A complete log of this run can be found in:

76 error C:UsersJenisAppDataLocalnpm-cache_logs2022-07-08T19_46_57_590Z-debug-
0.log

Add href to auto complete list

I need a little help with jquery. I am trying to add link functionality to an auto complete list. Basically, it displays suggested links based on what is typed in the input. Below are the scripts that produce only the auto complete…

I am using a plugin (omitted from this post), but it can be viewed here if needed: https://www.cssscript.com/demo/autocomplete-typeahead-bootstrap-5/autocomplete.js

My code at the bottom of the HTML:

  <script>
    var datasrc = [
      {label: 'About', value: 'about.html'},
      {label: 'Components', value: 'components.html'},
      {label: 'Usage', value: 'usage.html'},
    ]
    const ac = new Autocomplete(document.getElementById('autosuggest'), {
      data: datasrc,
      treshold: 1,
      maximumItems: 8,
      onSelectItem: ({label, value}) => {
        console.log("user selected:", label, value);
      }
    });
  </script>

I ran into this post: JQuery Autocomplete Where the Results are Links – but I’m not sure how to integrate an “event function” into the above code.

Electronjs ipcRenderer doesn’t send ipcMain response to component

I am working on a React and Electron app, and I need to read and write to a user’s “userData” folder on their computer. I am using the ipc pattern outlined in the Electron docs for two-way communication, but my React component is just getting an undefined value when I try to use app.getPath(). When I console.log the value in ipcRenderer.invoke, I get the correct value but somewhere inbetween there and my React component it’s getting lost.

main.js (relevant ipc code is at the bottom)

const { app, BrowserWindow, protocol, ipcMain } = require('electron');
const path = require('path');
const url = require('url');
const fs = require('fs');

function createWindow() {
    const mainWindow = new BrowserWindow({
        width: 800,
        height: 600,

        webPreferences: {
            preload: path.join(__dirname, 'preload.js')
        }
    });

    const appURL = app.isPackaged
        ? url.format({
                pathname: path.join(__dirname, 'index.html'),
                protocol: 'file:',
                slashes: true
          })
        : 'http://localhost:3000';
    mainWindow.loadURL(appURL);

    if (!app.isPackaged) {
        mainWindow.webContents.openDevTools();
    }
}

function setupLocalFilesNormalizerProxy() {
    protocol.registerHttpProtocol(
        'file',
        (request, callback) => {
            const url = request.url.substr(8);
            callback({ path: path.normalize(`${__dirname}/${url}`) });
        },
        error => {
            if (error) console.error('Failed to register protocol');
        }
    );
}

app.whenReady().then(() => {
    createWindow();
    setupLocalFilesNormalizerProxy();

    app.on('activate', function () {
        if (BrowserWindow.getAllWindows().length === 0) {
            createWindow();
        }
    });
});

app.on('window-all-closed', function () {
    if (process.platform !== 'darwin') {
        app.quit();
    }
});

const allowedNavigationDestinations = 'https://my-electron-app.com';
app.on('web-contents-created', (event, contents) => {
    contents.on('will-navigate', (event, navigationUrl) => {
        const parsedUrl = new URL(navigationUrl);

        if (!allowedNavigationDestinations.includes(parsedUrl.origin)) {
            event.preventDefault();
        }
    });
});

ipcMain.on('write-file', (_, filePath, content) => {
    fs.writeFile(filePath, content, function () {
        return 0;
    });
});

ipcMain.handle('get-path', () => {
    let path = app.getPath('userData');
    return path;
});

ipcMain.handle('read-file', () => {
    let path = app.getPath('userData');
    let data = fs.readFileSync(`${path}/tree.json`);
    return data;
});

preload.js

const { contextBridge, ipcRenderer } = require('electron');

process.once('loaded', () => {
    contextBridge.exposeInMainWorld('versions', process.versions);
});

contextBridge.exposeInMainWorld('electron', {
    writeFile: (filePath, content) => {
        ipcRenderer.send('write-file', filePath, content);
    },
    getPath: () => {
        ipcRenderer.invoke('get-path'); // when console.logging the result from this I get the correct path
    },
    readFile: () => {
        ipcRenderer.invoke('read-file');
    }
});

react component

import React from 'react';
// Redux
import { Provider } from 'react-redux';
import store from './redux/store';
// Components
import Note from './components/Note';
import Section from './components/Section';
import IconButton from './components/IconButton';
// Icons
import addIcon from './assets/add.png';
import saveIcon from './assets/save.png';
// Styles
import './styles/App.css';

const App = () => {
    function getSavePath() {
        let path = window.electron.getPath();
        console.log(path); // undefined
    }

    return (
        <div className='App'>
            <Provider store={store}>
                <Section />
                <Note />
                <IconButton iconName={addIcon} classes='IconButton-btn-lg IconButton-bot-left' />
                <IconButton
                    iconName={saveIcon}
                    classes='IconButton-btn-lg IconButton-bot-right'
                    action={getSavePath}
                />
            </Provider>
        </div>
    );
};

export default App;

add points to user via json

if(message.content.startsWith(prefix + "addpoints")) {

        let pUser = args[1];

        if (!points[pUser.id]) points[pUser.id] = {
            points: 0
        };

        const addition = parseInt(args[1])

        //const fpoints = points[pUser.id] + addition

        points[pUser.id].points++;

        fs.writeFile("./points.json", JSON.stringify(points), (err) => {
            if (err) logchannel.send({ embeds: [errorembed] })
            console.log(err)
        });

        
    }

Hi i want to make a system that gives user points for example if he behaves good. Then i want to have the option to give him points and save that in a json file. I hope this helps

Please also answer with the right place to put the code in thanks

How to check consol.log and play sound in JavaScript

I am planning for queue system application using WebSocket ,PHP ,MySQL ,HTML to send console.log from one client to another to play sound for next queue ,
now I want to check in clinet2 if console.log value which I receive it client =’Hello From Client1!’ paly sound or if = ‘another message’ do action.

    Client1
    <button onclick="sendMessage()">Send Msg</button>
</body>
<script>
    // Create WebSocket connection.
    const socket = new WebSocket('ws://localhost:3000');

    // Connection opened
    socket.addEventListener('open', function (event) {
        console.log('Connected to WS Server')
    });

    // Listen for messages
    socket.addEventListener('message', function (event) {
        console.log('Message from server ', event.data);
    });

    const sendMessage = () => {
        socket.send('Hello From Client1!');
    }
</script>
    Client2
    <button onclick="sendMessage()">Send Msg</button>
</body>
<script>
    // Create WebSocket connection.
    const socket = new WebSocket('ws://localhost:3000');

    // Connection opened
    socket.addEventListener('open', function (event) {
        console.log('Connected to WS Server')
    });

    // Listen for messages
    socket.addEventListener('message', function (event) {
        console.log('Message from server ', event.data);
    });

    const sendMessage = () => {
        socket.send('Hello From Client2!');
    }
</script>

How do you append a React Component to an html element

I tried to add a React.icon too my button, but it’s a react component (with this syntax: ). My question now is how can I append this exact icon component to my button Element with DOM Manipulation?
This is my current code:

        const para = document.createElement("p");
        const node = document.createTextNode("New Button");
        const uList = document.getElementById("uList");
        const btn = <button ><BsIcons.BsClockHistory /></button>
        listEl.appendChild(btn);
        para.appendChild(node);
        listEl.appendChild(para);
        uList.appendChild(listEl);

Can I perfectly clone any ordinary Promise?

I want to write a cloneDeep function that clones any JS object. There are two distinct problems here:

  1. Self references.
  2. Exotic objects.

I want to focus on the latter. Exotic objects in ECMAScript are listed in this section: 10.4 Built-in Exotic Object Internal Methods and Slots. There, it mentions exotic objects like strings, bound functions, Arrays etc. Specifically, it does not mention RegExp.

So, my expectation was that given RegExp is an ordinary object, if I copy all its own properties (enumerable and non-enumerable) and its prototype, it will behave like the source RegExp object. But that is not true: it fails when I try to access the getter regex.source by explicitly saying it is not a RegExp object.

Digging further, I found that some user-inaccessible internal slots exist in ECMAScript for various objects only to be accessible through their constructors.

This leads me to believe either of the two is true:

  1. RegExp is also an exotic object somehow.
  2. It is an ordinary object but there is some other state I did not copy.

Which one of these is true? Because I am not able to wrap my head around an ordinary object with object-specific internal slots.

Javascript – date input in Safari – Validation: 31 of February Year

How can I validate the date of 31/02/any year in Safari?

In Chrome or Firefox, it can be validated by the attribute validity.badInput but in Safari is not working.

Let’s suppose I have a date field in a form and the field is not required but I want to know if the user fills in a wrong date such as: 31/02/2000 or 31/09/2000.

PS. Keep in mind that the value of the field is value=”” if the date is wrong.