Skip to content

Commit 2fdcad7

Browse files
committed
fix(web-component): fix target props issue.
1 parent 5ba2d8a commit 2fdcad7

File tree

3 files changed

+8
-16
lines changed

3 files changed

+8
-16
lines changed

react/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ Runs the project in development mode.
136136
# Step 1, run first, listen to the component compile and output the .js file
137137
npm run hoist
138138
# Step 2, listen for compilation output type .d.ts file
139-
npm run watch
140-
npm run css:watch
139+
npm run watch:wc
140+
npm run watch
141141
# Step 3, development mode, listen to compile preview website instance
142142
npm run start
143143
```

react/src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ export default function githubCorners(props: GitHubCornersProps) {
5151
styl.top = 0;
5252
}
5353
return (
54-
<github-corners width={size} height={size} href={props.href} position={fixed ? 'fixed' : 'absolute'} z-index={zIndex} style={style} fill={bgColor} color={color} {...styl} {...otherProps}></github-corners>
54+
<github-corners target="__blank" width={size} height={size} href={props.href} position={fixed ? 'fixed' : 'absolute'} z-index={zIndex} style={style} fill={bgColor} color={color} {...styl} {...otherProps}></github-corners>
5555
);
5656
}

web-component/src/index.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,15 @@ export class GithubCorners extends HTMLElement {
5555
color?: string;
5656
fill?: string;
5757
position?: string;
58+
target?: string;
5859
top?: string;
5960
left?: string;
6061
right?: string = '0';
6162
bottom?: string;
6263
transform?: string;
6364
warpper?: HTMLElement;
6465
static get observedAttributes(): string[] {
65-
return ['z-index', 'height', 'width', 'href', 'color', 'fill', 'position', 'top', 'left', 'right', 'bottom', 'transform'];
66+
return ['z-index', 'target', 'height', 'width', 'href', 'color', 'fill', 'position', 'top', 'left', 'right', 'bottom', 'transform'];
6667
}
6768
constructor() {
6869
super();
@@ -73,18 +74,6 @@ export class GithubCorners extends HTMLElement {
7374
shadow.appendChild(this.ownerDocument.importNode(TEMPLATE.content, true));
7475
this.warpper = shadow.getElementById('warpper');
7576

76-
// const svg = warpper.firstElementChild as SVGAElement;
77-
// console.log('>>>href', this.getAttributeNames())
78-
// console.log('>>>hre222f', warpper, warpper.querySelector('a'))
79-
// ;[...this.getAttributeNames(), 'right'].forEach((name) => {
80-
// if (/(z-index|height|width|color|fill|position|top|left|right|bottom|transform)/.test(name.toLocaleLowerCase())) {
81-
// svg.style[name as any] = this.getAttribute(name) || this[name as keyof GithubCorners] as any;
82-
// console.log('~~~', name, this['left'], this.getAttribute(name))
83-
// } else {
84-
// console.log('name::', name, this.getAttribute(name))
85-
// warpper.setAttribute(name, this.getAttribute(name));
86-
// }
87-
// });
8877
this.update();
8978
}
9079
update() {
@@ -97,6 +86,9 @@ export class GithubCorners extends HTMLElement {
9786
}
9887
});
9988
}
89+
connectedCallback() {
90+
this.update()
91+
}
10092
attributeChangedCallback(name: string, oldValue: string, newValue: string) {
10193
this.update()
10294
}

0 commit comments

Comments
 (0)