Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
skatejs-named-slots
Advanced tools
A polygap (partial polyfill) for the Shadow DOM Named Slot API using SkateJS.
Working example: http://jsbin.com/weboki/31/edit?js,output
What this polyfill does is override native methods so that it can check added / removed elements for a slot
attribute, or use a default. It uses this slot as a property name and sets that property with information regarding the change. From there, you do the work.
On top of this, it needs to report only the nodes that are contained in slots from native accessors such as chilNodes
, children
, etc.
For example, let's assume we have some initial content. This is what your consumer would write.
<my-component id="example">
<p slot="content">paragraph 1</p>
<p slot="content">paragraph 2</p>
</my-component>
And you want it to result in:
<my-component id="example">
<div class="wrapper">
<p slot="content">paragraph 1</p>
<p slot="content">paragraph 2</p>
</div>
</my-component>
However, you don't want your consumers to worry, or know about .wrapper
.
There are some helpers that make using with Skate a lot simpler.
import slots from 'skatejs-named-slots';
skate('my-component', {
properties: {
content: slots.property({
set (elem, data) {
const wrapper = elem.querySelector('.wrapper');
wrapper[data.type].apply(wrapper, data.args);
}
})
},
render: slots.render(function (elem) {
elem.innerHTML = '<div class="wrapper"></div>';
})
});
And if you like writing in a more functional approach, you can use skatejs-dom-diff.
import diff from 'skatejs-dom-diff';
import slots from 'skatejs-named-slots';
skate('my-component', {
properties: {
content: slots.property({ set: skate.render }
},
render: slots.render(diff.render(function (elem) {
return diff.vdom.element('div', { 'class': 'wrapper' }, elem.content.nodes);
}))
});
The following lists are an exhaustive representation of what this polygap supports and why for the following interfaces:
Note:
HTMLElement
and any prototypes more specific are not polyfilled for simplicity.Object.getOwnPropertyDescriptor()
See https://bugs.webkit.org/show_bug.cgi?id=49739 for more info. We need to be able to bypass the overrides if modifying the prototypes. This does have performance implications but since only web component elements get these overrides, these are minimised. We'll be gathering some performance data on this soon.These are members which are already polyfilled.
Element.innerHTML
Node.childNodes
Node.firstChild
Node.lastChild
Node.textContent
ParentNode.children
Node.appendChild()
Node.hasChildNodes()
Node.insertBefore()
Node.removeChild()
Node.replaceChild()
These are members which are not yet polyfilled but are planned to be.
ParentNode.childElementCount
ParentNode.firstElementChild
ParentNode.lastElementChild
These are members which are not yet polyfilled but are up for discussion.
Element.id
NonDocumentTypeChildNode.nextElementSibling
NonDocumentTypeChildNode.previousElementSibling
Node.nodeValue
Node.nextSibling
Node.nodeValue
Node.parentNode
Node.parentElement
Node.previousSibling
Element.getElementsByClassName()
Element.getElementsByTagName()
Element.getElementsByTagNameNS()
Node.cloneNode()
Node.compareDocumentPosition()
Node.contains()
Node.normalize()
These are members which are not polyfilled and probably never will be because it's likely not necessary.
Element.accessKey
Element.attributes
Element.classList
Element.className
Element.namespaceURI
Element.tagName
Node.baseURI
Node.nodeName
Node.nodeType
Node.ownerDocument
Element.getAttribute()
Element.getAttributeNS()
Element.getBoundingClientRect()
Element.getClientRects()
Element.hasAttribute()
Element.hasAttributeNS()
Element.hasAttributes()
Element.querySelector()
Element.querySelectorAll()
Element.releasePointerCapture()
Element.removeAttribute()
Element.removeAttributeNS()
Element.setAttribute()
Element.setAttributeNS()
Element.setPointerCapture()
EventTarget.addEventListener()
EventTarget.dispatchEvent()
EventTarget.removeEventListener()
Node.isDefaultNamespace()
Node.isEqualNode()
Node.lookupNamespaceURI()
Node.lookupPrefix()
FAQs
A polygap (partial polyfill) for the Shadow DOM Named Slot API.
The npm package skatejs-named-slots receives a total of 0 weekly downloads. As such, skatejs-named-slots popularity was classified as not popular.
We found that skatejs-named-slots demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.