skatejs-named-slots
Advanced tools
Comparing version 0.2.0 to 0.2.1
{ | ||
"name": "skatejs-named-slots", | ||
"description": "A polygap (partial polyfill) for the Shadow DOM Named Slot API.", | ||
"main": "lib/index.js", | ||
"main": "dist/index.js", | ||
"authors": [], | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
@@ -8,9 +8,7 @@ { | ||
"scripts": { | ||
"test": "karma start --single-run", | ||
"test/watch": "karma start", | ||
"test": "sk-tests", | ||
"test/watch": "sk-tests-watch", | ||
"test/perf": "karma start --single-run --perf", | ||
"build": "rollup --config && rollup --config --min", | ||
"lint": "eslint -c node_modules/skatejs-build/.eslintrc src", | ||
"prerelease": "npm test && eslint -c node_modules/skatejs-build/.eslintrc src && npm run build", | ||
"semantic-release": "semantic-release pre && npm publish && semantic-release post" | ||
"prepublish": "sk-bundle" | ||
}, | ||
@@ -37,4 +35,3 @@ "repository": { | ||
"eslint-plugin-react": "^3.16.1", | ||
"skatejs-build": "1.1.0", | ||
"semantic-release": "^4.3.5" | ||
"skatejs-build": "2.1.1" | ||
}, | ||
@@ -51,3 +48,3 @@ "dependencies": { | ||
}, | ||
"version": "0.2.0" | ||
"version": "0.2.1" | ||
} |
@@ -291,3 +291,3 @@ import { eachChildNode, eachNodeOrFragmentNodes } from './util/each'; | ||
if (!canPatchNativeAccessors && !slot.childNodes.push) { | ||
staticProp(slot, 'childNodes', []); | ||
staticProp(slot, 'childNodes', [...slot.childNodes]); | ||
} | ||
@@ -643,2 +643,15 @@ | ||
// when we are doing this: root.innerHTML = "<slot><div></div></slot>"; | ||
// slot.__childNodes is out of sync with slot.childNodes. | ||
// to fix it we have to manually remove and insert them | ||
if (canPatchNativeAccessors && getNodeType(firstChild) == 'slot' && (firstChild.__childNodes.length != firstChild.childNodes.length)) { | ||
while (firstChild.hasChildNodes()) { | ||
firstChild.removeChild(firstChild.firstChild); | ||
} | ||
for (let i=0; i<firstChild.__childNodes.length; i++) { | ||
firstChild.appendChild(firstChild.__childNodes[i]); | ||
} | ||
} | ||
// When we polyfill everything on HTMLElement.prototype, we overwrite | ||
@@ -645,0 +658,0 @@ // properties. This makes it so that parentNode reports null even though |
@@ -82,2 +82,57 @@ import create from '../../lib/create'; | ||
}); | ||
describe('with slot/fallback content assigned by innerHTML', function () { | ||
let fallback; | ||
beforeEach(function () { | ||
root.innerHTML = '<slot><div></div></slot>'; | ||
slot = root.firstChild; | ||
fallback = slot.firstChild; | ||
}); | ||
it('should have fallback nodes', function () { | ||
expect(slot.childNodes.length).to.equal(1); | ||
expect(slot.childNodes[0]).to.equal(fallback); | ||
}); | ||
it('should have no assigned nodes', function () { | ||
expect(slot.____assignedNodes.length).to.equal(0); | ||
expect(slot.assignedNodes().length).to.equal(0); | ||
}); | ||
it('should be in a fallback state', function () { | ||
expect(slot.____isInFallbackMode).to.equal(true); | ||
}); | ||
describe('when assigned nodes', function () { | ||
let newNode; | ||
beforeEach(function () { | ||
newNode = create('div'); | ||
host.appendChild(newNode); | ||
}); | ||
it('should contain assigned nodes', function () { | ||
expect(slot.assignedNodes()[0]).to.equal(newNode); | ||
}); | ||
it('should not be in a fallback state', function () { | ||
expect(slot.____isInFallbackMode).to.equal(false); | ||
}); | ||
describe('are removed', function () { | ||
beforeEach(function () { | ||
host.removeChild(newNode); | ||
}); | ||
it('should not contain the assigned nodes', function () { | ||
expect(slot.assignedNodes().length).to.equal(0); | ||
}); | ||
it('should return to a fallback state', function () { | ||
expect(slot.____isInFallbackMode).to.equal(true); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
3
1
107160
32
2379