{"id":20514156,"url":"https://github.com/webreflection/element-observer","last_synced_at":"2025-04-14T00:09:37.576Z","repository":{"id":48395214,"uuid":"351402277","full_name":"WebReflection/element-observer","owner":"WebReflection","description":"A MutationObserver inspired observer for Custom Elements like mutations on any DOM element.","archived":false,"fork":false,"pushed_at":"2021-08-08T11:02:34.000Z","size":19,"stargazers_count":31,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-14T00:09:16.024Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WebReflection.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-03-25T10:54:53.000Z","updated_at":"2024-12-16T13:21:29.000Z","dependencies_parsed_at":"2022-08-24T09:20:29.356Z","dependency_job_id":null,"html_url":"https://github.com/WebReflection/element-observer","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebReflection%2Felement-observer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebReflection%2Felement-observer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebReflection%2Felement-observer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebReflection%2Felement-observer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WebReflection","download_url":"https://codeload.github.com/WebReflection/element-observer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248799955,"owners_count":21163404,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T21:15:02.365Z","updated_at":"2025-04-14T00:09:37.530Z","avatar_url":"https://github.com/WebReflection.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ElementObserver\n\n## Update\n\nDon't miss out [Pretty Cool Elements](https://github.com/WebReflection/p-cool#readme), which is entirely based on *Custom Elements* primitives, and it's even easier to use, and graceful enhance, with any project out there 👍\n\n- - -\n\nA *MutationObserver* inspired observer for *Custom Elements* like mutations on any DOM element.\n\n```js\nimport ElementObserver from '@webreflection/element-observer';\n\nconst observer = new ElementObserver({\n  // optional, used only if options for attributes are used\n  attributeChangedCallback(element, name, oldValue, newValue) {\n    // all observed attributes will be triggered right away if present,\n    // when the element is observed, and *before* connectedCallback,\n    // as it is for Custom Elements\n  },\n\n  // optional, used when the element is connected\n  connectedCallback(element) {\n    // if the element is already connected when observed, this is triggered.\n  },\n\n  // optional, used when the element is disconnected\n  disconnectedCallback(element) {}\n});\n\nobserver.observe(\n  observedElement,\n  // optional, if present is used to define attributes\n  {\n    // optional, if omitted will observe all attributes\n    attributeFilter: ['only', 'these'],\n    // optional, if omitted oldValue is always null\n    attributeOldValue: true,\n    // optional, if any of the previous properties are defined,\n    // this is implicitly set as true\n    attributes: true\n  }\n);\n\nobserver.disconnect(\n  // optional, if an element is passed, only that element\n  // stops being observed, otherwise all observed elements\n  // will immediately stop being observed\n  observedElement\n);\n```\n\nSee [MutationObserver.observe()](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver/observe) to better understand attributes properties.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebreflection%2Felement-observer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebreflection%2Felement-observer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebreflection%2Felement-observer/lists"}