New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@lwrjs/client-modules

Package Overview
Dependencies
Maintainers
8
Versions
495
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lwrjs/client-modules - npm Package Compare versions

Comparing version 0.0.2-alpha36 to 0.0.2-alpha37

33

build/modules/lwr/init/init.js

@@ -0,1 +1,11 @@

// TODO: This is a temporal workaround until https://github.com/salesforce/lwc/pull/2083 is sorted
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import { createElement } from 'lwc';
function initializeWebComponent(elementName, Ctor) {
return createElement(elementName, {
is: Ctor
});
}
/**

@@ -11,2 +21,4 @@ * Convert a module specifier into a valid CustomElement registry name:

*/
function toKebabCase(specifier) {

@@ -29,10 +41,9 @@ return specifier.replace(/\/v\/[a-zA-Z0-9-_.]+$/, '').replace('/', '-').replace(/([A-Z])/g, c => `-${c.toLowerCase()}`);

// Kebab-case the specifier
const elementName = toKebabCase(moduleSpecifier); // Add the root to the CustomElementRegistry
const elementName = toKebabCase(moduleSpecifier); // Append the root element to the DOM, if it does not exist
// this is for SPA like routes (one component at the root level) utilizing the lwr-root directive
customElements.define(elementName, ctor.CustomElementConstructor); // Append the root element to the DOM, if it does not exist
let el = document.body.querySelector(elementName);
if (!el) {
el = document.createElement(elementName);
el = initializeWebComponent(elementName, ctor);

@@ -46,2 +57,16 @@ if (container) {

}
} else {
// We have rendered/ssred an HTML page and we need to reify the components
// Due to the bug described on the header, for each custom element
// we collect the attributes and we replace the element with the new synthetic contructor
const customElements = document.querySelectorAll(elementName);
customElements.forEach(customElement => {
const newElement = initializeWebComponent(elementName, ctor);
for (const attr of customElement.attributes) {
newElement.setAttributeNode(attr);
}
customElement.parentElement.replaceChild(newElement, customElement);
});
}

@@ -48,0 +73,0 @@ });

6

package.json

@@ -7,3 +7,3 @@ {

},
"version": "0.0.2-alpha36",
"version": "0.0.2-alpha37",
"homepage": "https://lwr.dev/",

@@ -35,3 +35,3 @@ "repository": {

"@locker/sandbox": "^0.12.2",
"@lwrjs/shared-utils": "0.0.2-alpha36"
"@lwrjs/shared-utils": "0.0.2-alpha37"
},

@@ -54,3 +54,3 @@ "lwc": {

},
"gitHead": "90780d8ce526e05385aa60f74bf86cd1716268e8"
"gitHead": "499acedb8f2dabcb2a1f5dc303dd3efe459de414"
}

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc